Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1.Create an algorithm that accepts user input of their name in a last name-comma-firstname format (e.g., Prasad, Jay) and displays it as first name, space,

Q1.Create an algorithm that accepts user input of their name in a last name-comma-firstname format (e.g., Prasad, Jay) and displays it as first name, space, and last name (e.g.,Jay Prasad). (Do NOT use the split operation; that will be discussed later.) Q2.o guard against bad user input. That is, display in Fahrenheit a temperature provided in Celsius by the user. However, if the user enters something that cannot be used, display the message - Bad Input - instead. Note that temperature input as a decimal, e.g., 50.5, should be acceptable. Q3.so the user is prompted for an input until a valid input is obtained. That requirement is reproduced here for your convenience: Create an algorithm that asks users for their last name, validates it (i.e., checks it against business rules), and then displays it as confirmation with only the first letter capitalized, e.g., Prasad. If the name is not valid per our business rules, the display should be Invalid Name instead. The rules for last names at our business are: Names must be no longer than 20 characters but must be at least two characters. Names may have an apostrophe (e.g., ORourke) and/or a hyphen (e.g., SmithBarnes) but no other punctuation, no spaces, and no numbers. For example, we do not allow Smith Jr. (has space and period) or Smith III (has space). Q4.Write a program that computes the fuel efficiency of a multi-leg journey. The user will provide the initial odometer reading at the very beginning of the journey and then information about a series of legs. For each leg, the user provides the odometer reading at the end of the leg (which also serves as the reading for the start of the next leg) and the amount of gas used. If the amount of gas entered is 0, that leg should be excluded from the calculation. The user signals the end of the trip by entering -1 for the odometer reading. The program should display the miles per gallon (MPG) achieved for each leg and for the entire trip. (The MPG should be rounded to two places after the decimal.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

quds.bmp HTML :

Answered: 1 week ago