Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello so I have this c++ assignment which I would like to get help on. I really appreciate it :) Exercise A: Write a simple

Hello so I have this c++ assignment which I would like to get help on. I really appreciate it :)

Exercise A:

Write a simple if/else program Months. It asks the user to enter a month (1 = January, 2 = February, and so on) and then prints the number of days of the month. For February, print "28 days".

Example:

Please enter the month number: 5

May has 31 days!

Note: Make sure you use if/else if statement and trailing else statement to take care of unwanted input like -1 or 13,14..etc.

Exercise B:

Write a program Smallest that reads three integers from the user and determines the smallest value.

In this case, you are asking the user to enter numbers, then tell them which one is the smallest. I am writing 6 test cases at the bottom.

It means you are running your code 6 times. The first time, your first number is 3, second number is 2, and the third number is 1. Your code should say, your smallest number is 1.

The second time when you run your code, your first number should be 1, the second is 2 and third is 3. The output should be 1.

in any test case, if you don't see the output 1, it means your code has some error. This program should work for any set of data.

Test Cases:

3 2 1

1 2 3

2 1 3

3 1 2

1 3 2

2 3 1

Exercise C:

Repeat the Exercise B. This time, instead of finding the smallest number, arrange them in ascending order (smallest to greatest).

Hint: This time you are finding the smallest number, middle number, and the largest number. Display them in order. Use the same test case.

Exercise D:

Write a program that inputs an integer. If the integer is greater than 100 or between 50 and 75 (inclusive) then output YES. Otherwise, output NO. Your program should use an if-else statement along with &&(and) and || (or) relational operator.

Example: numbers that would result in an output of YES: 101, 50, 75, 55,70,71,250 Example: numbers that would result in an output of NO: 49,76,100, 80, 10, -50, 0

Exercise E:

Write a switch statement to convert a letter grade into an equivalent numeric value on a four-point scale. Set the value of the variable gradeValue to 4.0 for an A or a, 3.0 for a B or b, 2.0 for a C or c, 1.0 for a D or d, and 0.0 for an F or f. For any other letter, set the value to 0.0 and display an error message.

Examples:

Please enter your grade, I will tell your grade value: B

Your grade value is: 3.0

Note: if the user enters b instead of B. It should display the same result. Value will not change with the case. Make sure to put the error message.

Exercise F: (Section 4.12)

Write a program that reads 3 strings from the keyboard (one word per line). Display the strings (one per line) in lexicographic order.

Below is a sample transaction:

Enter 3 strings (in any order): Hiya hi Bye

In lexicographic ordering, the strings you entered are:

Bye Hiya hi

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

What is the pH of a solution with a [OH-] = 4.83 x 10^-5 M?

Answered: 1 week ago