# Really struggling!! Need help with a java assignment... will be greatly appreciated!

• 02-21-2013, 06:33 PM
daveg
Really struggling!! Need help with a java assignment... will be greatly appreciated!
Ok so this is the assignment:

The daily sales amount of a company product for seven days is as follows: 175, 225, 0, 200, 325, 275, 60. Write a program so that the average of sales is increased by x units from the 8th day to the 14th day. x = 1 or 2 or 5 or 10 etc.

So basically I have the code for figuring out the average of those first seven days given but I need to ask the user how much they would like to increase the average sales by for each day and given that number what is the amount of sales for the 8th day till the 14th day.

This is what I have so far:

Code:

```import java.util.Scanner; public class sales{   public static void main(String[] args){   Scanner user_Input = new Scanner(System.in);           double []sales = {175, 225, 0, 200, 325, 275, 60};           double sum = 0, avg;           int averageIncrease;                 int i;           for (i = 0; i < 7; ++i){             sum = sum + sales[i];             System.out.println("sales[" + i + "] = " + sales[i]);           }           avg = sum/i;           System.out.println("average  = " + avg);                     System.out.println("What is the increase in average sales from 8th day onwards?");           averageIncrease = user_Input.nextInt();           }   }```
• 02-21-2013, 08:20 PM
Norm
Re: Really struggling!! Need help with a java assignment... will be greatly appreciat
Quote:

need to ask the user
Use println to print out the message to ask the user a question
use one of the Scanner class's methods to read the user's response

Please edit your post and wrap the code in code tags.BB Code List - Java Programming Forum - Learn Java Programming