this is the original 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.
heres what i got so far:
import java.util.Scanner; public class sales2{ 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; double newSum = 0; int averageIncrease; double newSales = 0; int i, k; 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); for (k = 8; k < 15; k++) { System.out.println("How much would you like to increase average sales by?"); averageIncrease = user_Input.nextInt(); avg = avg + averageIncrease; newSum = avg * k ; newSales = newSum - sum; System.out.println("New sales for day[" + k + "] = " +newSales); } } }
Still having a hard time to figure out how to calculate the right amount of sales for days 9-14. I was able to figure out day 8 by subtracting the new sum from the old sum but cant figure out how to get it to subtract the old sum from the first sales array as well as the previous days sorry if this sounds a little confusing.