import java.util.Scanner;
public class Sales
{
public static void main (String[] args)
{
Scanner scan = new Scanner(System.in);
String[] name = new String[5];
double[] sales = new double[5];
for (int i=0; i<5; i++) {
System.out.println ("What is the name of the person?");
name[i] = scan.nextLine();
System.out.println ("How much did he/she sell?");
sales[i] = scan.nextDouble();
}
for (int j=0; j<5; j++) {
System.out.println (name[j] + " sold " + sales[j]);
}
int sum = 0;
for (double k : sales){
sum+=k;
}
double avg = sum / 5;
System.out.println ("The average sales is: " + avg);
for (int i = 0; i < 5; i++) {
if (sales[i] >= avg){
System.out.println (name[i] + " sold more than the average sales.");
}
}
}
}
(This code is only a portion of the program.. sorry if it's kinda messy[im a beginner])
This is the issue...
It outputs like this:
What is the name of the person?
Patrick
How much did he/she sell?
8000
What is the name of the person?
How much did he/she sell?
The lines in bold are the issue. I want to enter a different name and amount, but it asks me twice at the same time. Any help will be greatly appreciated. Thank you.