Hi, I am new to Java and part of my college assignment is to complete a series of exercises creating java programs and test them in the command window.
I have missed some lessons due to illness/being away and now i'm struggling with a few and I can't figure out what i'm doing wrong although I know it must be something relatively simple if I knew how...
My code is supposed to ask for an input 10 times, then calculate and output the total of all commission then output the average. At first I had commission++ below the input which was adding 1 plus the input each time which was wrong and I can't figure out whether i am missing a variable or if my maths is just totally wrong (not skilled in either area).
Please help....
import java.util.Scanner; class commission { public static void main (String [] args) { Scanner input = new Scanner(System.in); int commission, totcom, staff, comav; staff = totcom = comav = 0; // set the number to 0 for (staff = 1; staff <=10; staff++) { System.out.println("Please input the amount of commission"); commission = input.nextInt(); //commission+; totcom = (commission * staff ); comav = (commission / staff); } System.out.println("================================"); System.out.println("The amount of commission overall is " + totcom); System.out.println("================================"); System.out.println("The average amount of commission is " + comav); } }