Results 1 to 2 of 2
- 02-21-2013, 05:33 PM #1
Member
- Join Date
- Feb 2013
- Posts
- 1
- Rep Power
- 0
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(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(); } }Last edited by daveg; 02-21-2013 at 07:58 PM.
- 02-21-2013, 07:20 PM #2
Re: Really struggling!! Need help with a java assignment... will be greatly appreciat
Use println to print out the message to ask the user a questionneed to ask the user
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 ProgrammingIf you don't understand my response, don't ignore it, ask a question.
Similar Threads
-
Help would be Greatly Appreciated.. please
By aejames23 in forum New To JavaReplies: 6Last Post: 11-04-2012, 10:54 PM -
Using a loop to prevent a program from closing? Help greatly appreciated :)
By RarkMowe in forum New To JavaReplies: 5Last Post: 10-24-2012, 07:17 PM -
What's wrong with my code? (Danish java-programmer would be greatly appriciated!)
By spande in forum New To JavaReplies: 32Last Post: 02-29-2012, 09:21 AM -
Java program Fillarray method error :[ help is greatly needed pelase
By stan989 in forum New To JavaReplies: 5Last Post: 12-08-2011, 07:54 PM -
Java Calculator Help Would Be Greatly Appreciated
By TommyR in forum New To JavaReplies: 1Last Post: 03-14-2011, 09:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks