Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C++ Please (1) Write an if statement that assigns 100 to x when y is equal to 0. 2) Write an if/else statement that

IN C++ Pleaseimage text in transcribed

(1) Write an if statement that assigns 100 to x when y is equal to 0. 2) Write an if/else statement that assigns 0 to x when y is equal to 10. Otherwise it should assign 1 to x. (3) Using the following chart, write an if/else if statement that assigns 0.10, 0.15, or 0.20 to commission, depending on the value in sales. Assume Sales to be greater than zero. Sales Commission Rate Up to $10,000 10% $10,000 to $15,000 15% Over $15,000 20% (4) Write an if statement that prints the message "The number is valid" if the variable grade is within the range 0 through 100. (5) Write an if statement that prints the message "The number is valid" if the variable temperature is within the range-50 through 150. (6) Write an if statement that prints the message "The number is not valid" if the variable hours is outside the range 0 through 80. HINT: Use the OR operator. (7) Assume str1 and str2 are string objects that have been initialized with different values. Write an if/else statement that compares the two objects and displays the one that is alphabetically greater. 8) This is problem 58 in your textbook. The following program has errors, fe4-58.cpp. Take a look at the starter code and download it to work in your IDE to correct the errors. Then upload and submit it here for grading. (9) Write a program that reads in three names from the user and stores them in three separate string variables. Then sort them lexicographically and print the results to the screen. Example output is as follows: Enter three names: Charlie Able Baker Output: Able Baker Charlie (10) Math Tutor: This is a modification to the Math Tutor program from Assignment 2. Write a program that can be used as a math tutor for a young student. The program should display two random numbers (between 50 - 450) to be added, such as: 247 +129 376 The program should wait for the student to enter the answer. If the answer is correct, a message of congratulations should be printed to the screen. If the answer is incorrect, a message should be printed showing the correct answer. After ether of these events, the program should end. In this program you are essentially validating the user's entry. 11) This program will not be autograded. Submit your code here and I will grade it by hand. Write a program that uses a switch statement to displays the following menu (see example Program 4-23): Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit If the user enters 1, the program should ask for the radius of the circle and then display its area. Use the following formula: area = Nr 2. Validate the entry to only accept non-negative numbers for radius. Use a constant variable for Pl and set it equal to 3.1419. If the user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle's area. Use the following formula: area = length = width. Validate the entry to only accept non-negative numbers for length and width. If the user enters 3, the program should ask for the length of the triangle's base and its height, and then display its area. Use the following formula: area = base* height * 0.5 Validate the entry to only accept non-negative numbers for base and height. If the user enters 4, the program should end. The program should also end after displaying the results from one of the above calculations or displaying an error message if the user enters an invalid entry. This will feel very clunky but we have not learned the necessary statements yet to loop so that the program only ends after the user enter 4. Stay tuned, this will be next week's lesson

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

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions