Question

IN JAVA PLEASE This project is to calculate the total of numbers entered by the user....

IN JAVA PLEASE This project is to calculate the total of numbers entered by the user. The number of user input is decided by the number of characters of user’s full name. Get the user’s full name with one statement. If the user enters “Quit”, the system will quit. Based on the number of characters of the user’s name, ask the user to enter that many numbers and calculate the total. For example, if the user name is “Mark Twain”, it has 9 characters (space is not counted). Then you will ask the user to enter 9 numbers and calculate the total. On the other hand, if the user name is “Jane Austin”, it has 10 characters. You will ask the user to enter 10 numbers and calculate the total. Display the outcome appropriately versed and formatted Imagine that this system is being used by multiple users. Therefore, you must allow the above process to run forever until the user decides to quit by entering “Quit” (both upper case or lower case). Hint: Remember to reinitialize total each round. Remember to use nextLine() to read the ‘\n’ after the last number is entered. Remember the break; statement that transfers control out of the loop.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class Total {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       String name="";
       while(true) {
           //reading name
           System.out.print("Enter your name: ");
           name=sc.nextLine();
           //if it is quit than break the loop
           if(name.equalsIgnoreCase("quit"))
               break;
           int total=0;
           System.out.println("Enter "+name.length()+" numbers: ");
           //reading numbers and finding the total of entered numbers
           for(int i=0;i<name.length();i++)
               total=total+sc.nextInt();
           //printing the total
           System.out.println("Total of entered numbers : "+total);
           sc.nextLine();
       }
   }
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
IN JAVA PLEASE This project is to calculate the total of numbers entered by the user....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Ask the user to enter the user’s first name, the number of children the user has,...

    Ask the user to enter the user’s first name, the number of children the user has, and the average number of children per family in the user’s state. Define a variable to hold the difference between the user’s number of children and the average number of children per family. Print out the values of name, number of children, average number of children, and the difference formatted to 2 decimal places. can you create a flowchart

  • Using Java Create an application that creates and displays a list of names using an array....

    Using Java Create an application that creates and displays a list of names using an array. Then modify the application to create and use a list of numbers. Console for the names application Please enter a name or type “exit” to quit: Diane Please enter a name or type “exit” to quit: Joe Please enter a name or type “exit” to quit: Greta Please enter a name or type “exit” to quit: Henry Please enter a name or type “exit”...

  • // Group Names: // Date: // Program Description: //   Import required packages //--> //   Declare class...

    // Group Names: // Date: // Program Description: //   Import required packages //--> //   Declare class (SwitchDoLab) //--> {    //   Declare the main method    //-->    {        //   Declare Constant integers SUM = 1, FACTORIAL = 2, QUIT = 3.        //-->        //-->        //-->        //   Create an integer variable named choice to store user's option.        //-->        //   Create a Scanner object        //   Create...

  • In C++ Prompts the user to enter 5 numbers. Once the user has entered the 5...

    In C++ Prompts the user to enter 5 numbers. Once the user has entered the 5 numbers, the program should calculate and display the average of the 5 numbers.and The program prompts the user for one number at a time, without using for

  • RandomGame.cpp (2pt) Write a program that asks the user to enter his/her name. Then begin a...

    RandomGame.cpp (2pt) Write a program that asks the user to enter his/her name. Then begin a do while loop that asks the user to enter a number between 1 and 10. Have the random number generator produce a number 1 and 10. Display the user’s name and both numbers to the screen. Compare the two numbers and report if the entered number is greater than, less than, or the same as the generated number. Ask the user if he/she’d like...

  • This is Python The program should accept input from the user as either 7-digit phone number...

    This is Python The program should accept input from the user as either 7-digit phone number or 10-digit. If the user enters 7 characters, the program should automatically add "512" to the beginning of the phone number as the default area code. Dash (hyphen) characters do not count in input character count, but must not be random. If the user enters dashes the total character count must not exceed 12. The program should not crash if the user enters invalid...

  • In C++ Prompts the user to enter 5 numbers. Once the user has entered the 5...

    In C++ Prompts the user to enter 5 numbers. Once the user has entered the 5 numbers, the program should calculate and display the average of the 5 numbers.and no for(;;) while(1) while(true) do{//code}while(1); without cin The program prompts the user for one number at a time

  • Assignment Develop a program to analyze one or more numbers entered by a user. The user...

    Assignment Develop a program to analyze one or more numbers entered by a user. The user may enter one or more numbers for analysis. Input should be limited to numbers from 1 through 1000. Determine if a number is a prime number or not. A prime number is one whose only exact divisors are 1 and the number itself (such as 2, 3, 5, 7, etc.). For non-prime numbers, output a list of all divisors of the number. Format your...

  • Create a python script in Pycharm: 1) For your script you will need to get input...

    Create a python script in Pycharm: 1) For your script you will need to get input from a user, which will ask them to enter a password to be reviewed. This needs to be outside of your functions that you will create for your script. You will be passing the value of the user’s password entered as a parameter value to your functions. You will be creating four separate functions, you will have one function that verifies whether the user’s...

  • Write a SIMPLE JAVA program to store a positive number a user inputs until he enters 0. Print all the numbers entered at...

    Write a SIMPLE JAVA program to store a positive number a user inputs until he enters 0. Print all the numbers entered at the end. The dialog might look like: Enter Number: 1 Enter Number: 10 Enter Number: 0 You entered numbers 1, 10

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT