So I'm writing a code to ask the user how many weeks they go till they get paid, how many hours they worked each day, how much their pay rate is, and then compile it all. Only problem is that I can't get the numbers to add up right. I'm sure I haven't written the code properly since I'm new to this and self taught but maybe someone can help? When the program runs a second time (if they work 2 weeks) it over wrights the data stored in the variables.
import java.util.Scanner; public class paycheck1 { public static void main(String[] args) { double sunday = 0; double monday = 0; double tuesday = 0; double wednesday = 0; double thursday = 0; double friday = 0; double saturday = 0; System.out.println("How many weeks per paycheck?"); Scanner week = new Scanner (System.in); int weekc = week.nextInt(); int weekv = weekc; weekv++; int count = 1; while (count != weekv) { // check System.out.println ("count: " + count + "weekv: " + weekv); System.out.println ("How many hours did you work Sunday of week " + count + " ?"); Scanner scan = new Scanner (System.in); sunday = scan.nextDouble(); System.out.println ("How many hours did you work Monday of week " + count + " ?"); Scanner scan1 = new Scanner (System.in); monday = scan1.nextDouble(); System.out.println ("How many hours did you work Tuesday of week " + count + " ?"); Scanner scan2 = new Scanner (System.in); tuesday = scan2.nextDouble(); System.out.println ("How many hours did you work Wednesday of week " + count + " ?"); Scanner scan3 = new Scanner (System.in); wednesday = scan3.nextDouble(); System.out.println ("How many hours did you work Thursday of week " + count + " ?"); Scanner scan4 = new Scanner (System.in); thursday = scan4.nextDouble(); System.out.println ("How many hours did you work Friday of week " + count + " ?"); Scanner scan5 = new Scanner (System.in); friday = scan5.nextDouble(); System.out.println ("How many hours did you work Saturday of week " + count + " ?"); Scanner scan6 = new Scanner (System.in); saturday = scan6.nextDouble(); count ++; } double total = sunday + monday + tuesday + wednesday + thursday + friday + saturday; System.out.println ("In total, you worked " + total + " hours." ); System.out.println ("What is your hourly pay?"); Scanner scan7 = new Scanner (System.in); double pay = scan7.nextDouble(); double paytotal = pay*total; System.out.println ("Your paycheck for this period of " + weekc + " weeks will be $" + paytotal +"."); } }