I'm new to Java and have just learnt a little on Arrays. However I'm not very sure how I should apply them.
I have a main method which has a switch case. If the user chooses 1, it will prompt the user to enter the daily expenses for a week. If the user chooses 2, it will show the total amount of expenses for the week. I've decided to use arrays to store the the amount for everyday.
here's my code.
double[] monArray= new double[10];
double[] tuesArray= new double[10];
double[] wedArray= new double[10];
double[] thursArray= new double[10];
double[] friArray= new double[10];
double[] satArray= new double[10];
double[] sunArray= new double[10];
for(______________________________)
{
System.out.print("Enter Mon Charges : $");
monArray[n]= CspInput.readDouble();
System.out.print("Enter Tues Charges : $");
tuesArray[n]= CspInput.readDouble();
System.out.print("Enter Wed Charges : $");
wedArray[n]= CspInput.readDouble();
System.out.print("Enter Thurs Charges : $");
thursArray[n]= CspInput.readDouble();
System.out.print("Enter Fri Charges : $");
friArray[n]= CspInput.readDouble();
System.out.print("Enter Sat Charges : $");
satArray[n]= CspInput.readDouble();
System.out.print("Enter Sun Charges : $");
sunArray[n]= CspInput.readDouble();
After the user entered all the amount for week one, he will return to the choice menu. Then, when the user chooses 1 again and entered the new value for the faily expenses, it will be started as week 2, which will be displayed in choice 2 where it shoows the total amount for all the weeks.
So, what should I place inside the for loop so that the amount for the daily expenses will be stored in the arrays and not be over-written when the user chooses 1 and enter the daily expenses again?
And how do I calculated the total expenses for the week?