Results 1 to 2 of 2
  1. #1
    daveg is offline Member
    Join Date
    Feb 2013
    Rep Power

    Default 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:

    Java Code:
    import java.util.Scanner;
    public class sales{
       public static void main(String[] args){
       Scanner user_Input = new Scanner(;
              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();
    Last edited by daveg; 02-21-2013 at 07:58 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Really struggling!! Need help with a java assignment... will be greatly appreciat

    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
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Help would be Greatly Appreciated.. please
    By aejames23 in forum New To Java
    Replies: 6
    Last Post: 11-04-2012, 10:54 PM
  2. Replies: 5
    Last Post: 10-24-2012, 07:17 PM
  3. Replies: 32
    Last Post: 02-29-2012, 09:21 AM
  4. Replies: 5
    Last Post: 12-08-2011, 07:54 PM
  5. Java Calculator Help Would Be Greatly Appreciated
    By TommyR in forum New To Java
    Replies: 1
    Last Post: 03-14-2011, 09:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts