Write a program using an array that will process sales data

Write a program using an array that will process sales data for a week. Create an array that will store input data for the daily sales for a week (7 days). Using the array data determine the total sales for the week, the day of the week with the least number of sales and the day of the week with the highest sales.

Be sure to submit the .java, .class files, and two test runs of the program. The program may be written in one file unless you choose to create an object and tester. Use spacing, alignment, indentation and comments to provide a easily readable code.

Solution

import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
String wk[] = new String[]{\"sun\",\"mon\",\"tue\",\"wed\",\"Thu\",\"Fri\",\"sat\"};
Scanner scan = new Scanner(System.in);
System.out.println( \"Enter sales of 7 daya with spaces :\" );
System.out.println();   
int array[] = new int[7],total=0;
for(int i=0;i<7;i++) //Integer Input
{
int a=scan.nextInt();
array[i]=a;
}
for(int i=0;i<7;i++) //Total sales of the week
{
total+=array[i];
}
System.out.println( \"Total sales of the week is :\"+total );
int max = getMax(array); // Calling getMax() method for getting max value
System.out.println(\"Maximum Value is: \"+array[max]+\"->\"+wk[max]);
int min = getMin(array); // Calling getMin() method for getting min value
System.out.println(\"Minimum Value is: \"+array[min]+\"->\"+wk[min]);
}

public static int getMax(int[] inputArray) // Method for getting the maximum value
{
int maxValue = inputArray[0],i,y=0;
for(i=1;i < 7;i++)
{
if(inputArray[i] > maxValue)
{
maxValue = inputArray[i];
y=i;
}
}
return y;
}

public static int getMin(int[] inputArray) // Method for getting the minimum value
{
int minValue = inputArray[0],i,y=0;
for(i=1;i<7;i++)
{
if(inputArray[i] < minValue)
{
minValue = inputArray[i];
y=i;
}
}
return y;
}
}

out put 1:
run:
Enter sales of 7 daya with spaces :

56 88 554 74 69 14 75
Total sales of the week is :930
Maximum Value is: 554->tue
Minimum Value is: 14->Fri
BUILD SUCCESSFUL (total time: 24 seconds)


out put 2:
run:
Enter sales of 7 daya with spaces :

98 77 546 85 333 5 2
Total sales of the week is :1146
Maximum Value is: 546->tue
Minimum Value is: 2->sat
BUILD SUCCESSFUL (total time: 27 seconds)

Write a program using an array that will process sales data for a week. Create an array that will store input data for the daily sales for a week (7 days). Usin
Write a program using an array that will process sales data for a week. Create an array that will store input data for the daily sales for a week (7 days). Usin

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site