Write a
lastName, firstName Middle_Initial.
For example, the input
Mary Average User
should produce the output:
User, Mary A.
The input
Mary A. User
should also produce the output:
User, Mary A.
Your program should work the same and place a period after the middle initial even if the input did not contain a period. Your program should allow for users who give no middle name or middle initial. In that case, the output, of course, contains no middle name or initial. For example, the input
Mary User
should produce the output
User, Mary
If you are using C strings, assume that each name is at most 20 characters long. Alternatively, use the class string.
(Hint: You may want to use three string variables rather than one large string variable for the input. You may find it easier to not use getline.)
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Degarmo's Materials And Processes In Manufacturing
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with C++ from Control Structures to Objects (9th Edition)
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Electric Circuits. (11th Edition)
- (Modify) a. Modify the program you wrote for Exercise 7 to provide the mass of a person as an output, given his or her weight as an input to the program. Use your program to determine the mass of a person who weighs 140 lbf on Earth. b. Modify the program written for Exercise 7a to also output the person’s weight on Mars and the moon. The pull of gravity on Mars is 12.54ft/sec2=3.728m/s2,andonthemoonis5.33ft/sec2=1.625m/s2.arrow_forward(Program) Write a program to simulate the rolling of two dice. If the total of the two dice is 7 or 11, you win; otherwise, you lose. Embellish this program as much as you like with betting, different odds, different combinations for win or lose, stopping play when you have no money left or reach the house limit, displaying the dice, and so forth. (Hint: Calculate the dots showing on each die with theexpressiondots=(int)(6.0randomnumber+1), where random number is between 0 and 1.)arrow_forwardPython question Please explain this for me Thanks for your helparrow_forward
- Many documents use a specific format for a person's name. Write a program that reads a person's name in the following format: firstName middleName lastName (in one line) and outputs the person's name in the following format: lastName, firstInitial.middleInitial. Ex: If the input is: Pat Silly Doe the output is: Doe, P.S. If the input has the following format: firstName lastName (in one line) the output is: lastName, firstInitial. Ex: If the input is: Julia Clark the output is: Clark, J.arrow_forward24. Write a program which asks the user for an integer number and prints out whether the input number is a multiple of 7. A. Example 1 i. Input: • ii. Output: B. Example 2 i. Input: Please enter number: 9 ii. Output: Number is not a multiple of seven 25. Write a program which asks the user for two integer numbers (say N1 and N2) and prints out whether the input number NI is a multiple of N2. A. Example 1 i. Input: • B. Example 2 ii. Output: • i. Input: A. Example Please enter number: 49 Number is a multiple of seven i. Input: ii. Output: Number 40 is not a multiple of 3 26. Write a program which asks the user for an integer number and prints out whether the input number is even or odd. Please enter first number: 49 Please enter second number: 7 Number 49 is a multiple of 7 Please enter first number: 40 Please enter second number: 3 • Please enter number: 42 i. Input ii. Output: Number is even 27. Write a program that asks the user for an integer number and prints a pattern. A. Example…arrow_forwardHello, I was wondering if I could get help with this. The language I am using is Pythonarrow_forward
- Given the sample code above in generating a random number. Create a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don't display the computer's choice yet.) 2. The user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. (You can use a menu if you prefer.) 13. The computer's choice is displayed. 4. A winner is selected according to the following rules: a. If one player chooses rock and the other player chooses scissors, then rock wins. (The rock smashes the scissors.) b. If one player chooses scissors and the other player chooses paper, then scissor wins. (Scissors cuts paper.) c. If one player chooses paper and the other player…arrow_forward1. Write a pyrhon program that prints out a classic hangman stick figure. The program should ask the user to enter a number from 1-6 and the corresponding hangman should be printed. The value the user inputs corresponds to the number of incorrect guesses in a real hangman game and so the completeness of the hangman will correspond to the number of ‘incorrect guesses’ inputted by the user (e.g., if the user enters 1, then only the head of the hangman will be printed; full example below). Example:Enter a number from 1-6: 1O Enter a number from 1-6: 2O|Enter a number from 1-6: 3O\||Enter a number from 1-6: 4O\|/|Enter a number from 1-6: 5O\|/|/Enter a number from 1-6: 6O\|/|/ \ 2. Modify your program from problem 1 so that the user input is checked to be a validsingle digit (1-6) before printing the corresponding hangman. If the input is not valid, theninstead of a hangman the following message should be printed “Invalid input: you must enter asingle number from 1-6.” Example:Enter a…arrow_forwardWrite a program that reads from the user a character ('q' or 'c'). If the character is 'c', the program reads from the user the radius rof a circle and prints its area. • If the user enters 'q', the program asks the user to enter the length and width of a quadrilateral. We assume the quadrilateral is either a square or rectangle. You should print if the quadrilateral is square or rectangle. • Otherwise, it prints "Wrong character" PS: Use the following formulas: area of circle=3.14*r Sample Run1: Enter a character (q or c): q Enter the Length and Width: 80 150 |It is a rectangle Sample Run2: Enter a character (q or c): q Enter the Length and Width: 80 80 It is a square Sample Run3: Enter a character (q or c): c Enter the radius: 2 The area of the circle is 12.56 Sample Run4: Enter a character (q or c): d Wrong characterarrow_forward
- You found an exciting summer job for five weeks. It pays a per hour rate (which will be input to the program), and you will work the same number of hours each week (also input). Suppose that the total tax you pay on your summer job income is 14%. After paying the taxes, you spend 10% of your net (after tax) income to buy new clothes, accessories, and school supplies. After subtracting those items from your budget, you use 25% of the remaining money buy savings bonds. In addition, your parents buy additional savings bonds for you at 50% of the amount that you buy. Write a program that prompts the user to enter the pay rate per hour and the number of hours you will work each week. The program then outputs the following:• Your income before and after taxes for your summer job.• The money you spend on clothes, accessories, and supplies.• The money you spend to buy savings bonds.• The money your parents spend to buy additional savings bonds for you.Your input for this program should be only…arrow_forwardWrite a program that reads from a student his/her name and his/her ID which is formed of 8 digits. The program should display the day of registration and the starting hour of registration according to the below tables. First 4 digits to the left Registration Day Monday Tuesday WEdnesday 2018 2019 2020 First digit to the right Registration IHour 4 6 10 7-8arrow_forwardComputer Science Java programarrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr