Arush22

6.14 2-42 Even

Mar 7th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. 2. do/while
  2. 4. true
  3. 6. Hello
  4. Enter an int >
  5. Hello
  6. Enter an int >
  7. 8. sum is 54
  8. i is 19
  9. 10. product is 6
  10. i is 7
  11. 12. Hello
  12. Hello
  13. Hello
  14. Done
  15. 14. 2033
  16. 16. i is 39 and sum is 60
  17. 18. sum is 40
  18. 20. sum is 21
  19. i is 7
  20. 22. do {
  21. System.out.println("Type another integer >");
  22. int newNum = scan.nextInt();
  23. }
  24. while ( newNum > start );
  25. 24. for(countMultiplesOf7; countMultiplesOf7 < 4; countMultiplesOf7 ++){
  26. sum + = countMultiplesOf7 * 7;
  27. }
  28. 26. Scanner scan = new Scanner( new File ("Example.file"));
  29. int sum = 0;
  30. while( scan.hasDigit()){
  31. sum + = scan.nextDigit();
  32. }
  33. 28. Scanner scan = new Scanner(System.in);
  34. do{
  35. System.out.println("Type another integer >");
  36. int newNum = scan.nextInt();
  37. }while( newNum != 0 && newNum != 100 );
  38. 30. i never iterates so the while loop only executes once.
  39. 32. There is a semi colon after the parentheses of the for loop.
  40. 34. The while loop should have and not or.
  41. 36. There should be a semicolon in front of the while condition.
  42. 38. the program is reading the incrementor and the limit in the wrong order and place. place the i++ after the i < 3.
  43. 40. you place commas instead of semi colons so it doesn't know where the statements end. replace the commas in the for loop with semi colons.
  44. 42. You already declared a variable name i above, and you can't name two variable with the same name in one class. Remove the int in front of the i when initiating the i in the for loop.
Add Comment
Please, Sign In to add comment