Fill in the main method below. Your program should prompt the user to enter (int
ID: 3850364 • Letter: F
Question
Fill in the main method below. Your program should prompt the user to enter (integer) values, and will add them up as it goes, displaying the total after each entry. If the total reaches 100 or more, then your program should display "Too much" (instead of the total) and stop. Here is an example: Enter a value: 50 Total is 50 Enter a value: 25 Total is 75 Enter a value: 20 Total is 95 Enter a value: 5 Too much import java.util.Scanner: public static void main(String[] args) { Scanner s = new Scanner(System.in);Explanation / Answer
import java.util.Scanner;
class total
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
int total=0;
for(int i=0;total<100;i++)
{
System.out.print("Enter a value: ");
int n=s.nextInt();
total+=n;
if(total<100)
System.out.println("Total is "+total);
else
System.out.println("Too much");
}
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.