I want to store data from a for loop and add my answer up. The thing is every time the for loop executes another iteration it loses the data from the first iteration, for example lets say i want to go shopping on two days this week, i want to retain the info from the first iteration and second and then add them how would i do this
import java.util.Scanner;
Scanner keyboard = new Scanner(System.in);
int noDays;
float sClothes, sShoes, sFood;
public void mainMethod {
System.out.println("How many days are you going shopping this week: ");
noDays = keyboard.nextInt();
for(int i = noDays;i > 0; i-- ) {
System.out.println("How much did you spend on clothes today: ");
sClosthes = keyboard.nextFloat();
System.out.println("How much did you spend on shoes today: ");
sShoes.keyboard.nextFloat();
System.out.println("How much did you spend on food today: ");
sFood.nextFloat
}
}
