#introduction to JAVA task!

1 messages · Page 1 of 1 (latest)

sour prismBOT
#

<@&987246399047479336> please have a look, thanks.

sour prismBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

Of course! I'd be happy to help you with your Java task. Please provide the details of the task, and I'll guide you through the solution step by step.

inland berry
#

introduction to JAVA task!

ocean pewter
#

hiya !

#

it's better to copy/paste the text

#

so we can highlight important keywords like this

inland berry
# ocean pewter it's better to copy/paste the text

For the purpose of a software for keeping track of the revenue generated by employees in the sales department, define a QuarterlySales class that stores the number of sales, the revenue generated by each sale and the number of the quarter.
Then define another SalesPerson class for which a name(string) and an array of quarterly sales (exactly 4) are stored. For the classes implement the appropriate constructors and methods for the correct execution of the program.
Implement the following requirements:
• Method int sumSales(SalesPerson sp)* which will return sum of all the revenues in all quarters generated by the given worker.
• Method 'SalesPerson salesChampion(SalesPerson I arr)* which for the given array of sales employees will return the worker with the most generated revenue (of all quarters)
• Add the 'main' method, which will initialize an array of sales persons and quarters according to the input test cases. The number of sales employees is read from input in the first line, and then for each employee the name is read in the first line, and then for each of the quarters for that employee in the first line we have the number of sales, and then in the next line the revenue generated by each of those sales.
• On standard output, print the array of sales employees using the method void table(SalesPerson I arr)*, which will print a display for the array of sales persons in the following format (three spaces are used for printing space):

ocean pewter
ocean pewter
#

can you ?

#

cuz im busy at work rn

#

and can't read the hell of this

lofty lichen
#

First you start creating all the classes

#

Then declare the methoss

#

Do that and keep trying until u run into an issue

inland berry
#

import java.util.Scanner;

class QuarterlySales {

private int numOfSales;
private int [] revenues;
private int quarterNo;

public QuarterlySales(int numOfSales, int[] revenues, int quarterNo) {
    this.numOfSales = numOfSales;
    this.revenues = revenues;
    this.quarterNo = quarterNo;
}
@Override
public String toString() {
    
}

}

class SalesPerson {

private String name;
private QuarterlySales [] quarters;

public SalesPerson(String name, QuarterlySales[] quarters) {
    this.name = name;
    this.quarters = quarters;
}
@Override
public String toString() {

}

}

public class Main {

public static SalesPerson salesChampion(SalesPerson [] arr)
{

}
public static void table(SalesPerson [] arr)
{


}

public static void main(String[] args) {

    int n;
    Scanner input = new Scanner(System.in);
    n = input.nextInt();
    SalesPerson [] arr = new SalesPerson[n];
    for(int i=0;i<n;i++)
    {
        //your code goes here
    }

    table(arr);
    System.out.println("SALES CHAMPION: " + salesChampion(arr).getName());

}

}

inland berry
ocean pewter
#

Can you just tell us what u understand, and what u didnt or difficult to you!

#

I see you made some code thts good

#

Based on the description of the problem, it seems you're facing an object oriented (OO) topic

inland berry
#

exactly

ocean pewter
#

You need to understand it by identifying keywords potential to be classes

inland berry
#

actually now I've solved it all but there is only one problem left which i cant really understand what should i do

ocean pewter
#

What is it

inland berry
#

i dont know how to declare the class code into a file

ocean pewter
#

When you declare a class as public in a java file

#

It must have same name as the file

inland berry
#

ill try again one sec

#

still is not reading my file

ocean pewter
#

Which one?

inland berry
#

all of them

ocean pewter
#

You have a file "SalesPerson"

inland berry
#

btw this is a task from my school which i solve directly in my school website

ocean pewter
inland berry
#

yes

ocean pewter
#

Inside you have a class Main right?

inland berry
#

yes

ocean pewter
#

That class is defined public right?

#

Like this public class Main{}

inland berry
#

yes

ocean pewter
#

If yes it should be placed outside

#

That file

#

Or remove public from it

inland berry
#

one of my files

ocean pewter
#

Read what i told u

inland berry
ocean pewter
#

If the class is only needed inside that file or in the package where that file, it could be without public like this:

class Main{}

inland berry
#

yes but in my task its necessary to be public

#

thats where the main problem stands

ocean pewter
#

Then create a second file for it

#

Name it same as the class

#

And move it up there

inland berry
#

okay

ocean pewter
inland berry
#

it works now

#

thank uuu