0 Members and 2 Guests are viewing this topic.
public class count { public static void main(String[] args) { int lowest = 0; int total = 0; int numEntries = 0; String tempScore = JOptionPane.showInputDialog("Enter your test score (negative to exit):"); lowest = Integer.parseInt(tempScore); total += Integer.parseInt(tempScore); numEntries++; while (true) { tempScore = JOptionPane.showInputDialog("Enter your test score (enter a negative number to exit):"); if (Integer.parseInt(tempScore) < 0) { break; } else{ if (Integer.parseInt(tempScore) < lowest) { lowest = Integer.parseInt(tempScore); total += Integer.parseInt(tempScore); } else { total += Integer.parseInt(tempScore); } } numEntries++; } total = total-lowest; System.out.println("Lowest Score:" + lowest); System.out.println("Number of Total Entries: " + numEntries); System.out.println("Total:" + total); System.out.println("Average:" + (double)total/(numEntries-1));// System.out.println("your average of the test scores minus the lowest score is: " + total); } }
enter test numberlowest = test numbertotal += test numberloop {if score is negative { break}else{if score < low { lowest = score total += score}else{ total += score}number of entries ++//all math here and rest of program blah blah blah
thanks! yeah what I was doing is comparing the current score with the last score (low) and if it was lower than the last one then its the lowest... although now that im typing this lol im not sure what good that would do me since i still have to compare (lowest) to something.. if thats even how i did it! lol your right i did confuse myselfedit: why did you parseInt so many times, why not just once?
well, im just gonna use madskills since it looks more along the lines of my work because any of the others are actually too advanced and my teacher will know something is up.. so yeah I would but I might get in trouble for doing so. I hope you can understand