Question

This assignment is about data types and condition checking in C++. Ask the user to enter...

This assignment is about data types and condition checking in C++. Ask the user to enter three numbers, one after each other. The numbers can be a decimal numbers (one or two decimal precision, such as 5.4 or 6.32) or integer between 0 and 10. Then find maximum of three numbers and message the user. Examples runs are given below.

Example -1 Enter a number: 4.3

Enter a number: 0.5

Enter a number: 6.7

The max of three number: 6.7

Example -2 Enter a number: 0.30

Enter a number: 5

Enter a number: 0.7

The max of three number: 5

Example -3 Enter a number: 3

Enter a number: 3

Enter a number: 3

The max of three number: 3

PS: Assume that numbers are entered as described. You do not need to verify whether the format is correct or not.

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

Answer:

#include <iostream>

using namespace std;

int main()
{
double a, b, c;
cout<<"Enter a number: ";
cin>>a;
cout<<"Enter a number: ";
cin>>b;
cout<<"Enter a number: ";
cin>>c;
  
double max = a;
  
if(b>max)
{
max=b;
  
if(c>max)
max = c;
}
else if(c>max)
{
max = c;
}
  
cout<<"The max of three number: "<<max;
return 0;
}

Output:

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!

Add a comment
Know the answer?
Add Answer to:
This assignment is about data types and condition checking in C++. Ask the user to enter...
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 a message Ask the user how many time they want to...

    Ask the user to enter a message Ask the user how many time they want to print the message Then use "while","do-while" and "for" loop to print the message. Show the number at the beginning of the lines when printing. For example: Enter your message: Welcome to Java How many time you want to print this message: 3 Using "while" loop: 1=> Welcome to Java 2=> Welcome to Java 3=> Welcome to Java Using "do-while" loop: 1=> Welcome to Java...

  • Ask user to enter three numbers (a,b,c). Write a program (c++) that will print the value...

    Ask user to enter three numbers (a,b,c). Write a program (c++) that will print the value to the following equations: a. maximum value of one of these equations (functions separated by commas) (a, a+b, a-c) + maximum of (b, 2b-c, b+2a) b. maximum value of (3, c+3a, 0) + minimum of (ab-2, 3c, ac) Define functions max and min which will accept 3 numbers as arguments and return the mix and min of them correspondingly. Use these functions in order...

  • Example 3: Draw a flowchart that performs the following: Ask a user to enter a number....

    Example 3: Draw a flowchart that performs the following: Ask a user to enter a number. If the number is between 0 and 10, write the word blue. If the number is between 10 and 20, write the word red. if the number is between 20 and 30, write the word green. If it is any other number, write that it is not a correct color option. Example 4: Draw a flowchart to print all multiples of 5 between 1...

  • This program will ask the user to enter a number of players, then ask the user...

    This program will ask the user to enter a number of players, then ask the user for each player's name and score. Once all of the players have been entered, the program will display a bar chart with each of their scores scaled as a percentage of the maximum score entered. See below for details on exactly how this should work - an example transcript of how the program should work is shown below (remember that values entered by the...

  • 1. (sumFrom1.cpp) Write a program that will ask the user for a positive integer value. The...

    1. (sumFrom1.cpp) Write a program that will ask the user for a positive integer value. The program should use the for loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, ... 50. If the user enters a zero or negative number, a message should be given and the program should not continue (see Sample Run...

  • Create two java programs. The first will ask the user to enter three integers. Once the...

    Create two java programs. The first will ask the user to enter three integers. Once the three integers are entered, ask the user to enter one of three functions. The “average” if they want the average of the three numbers entered, enter “min” if they want the minimum and “max” if they want the maximum. Display the answer. Ask the user if they want to calculate another function for the three numbers. If so, loop and ask what function they...

  • Write a C program that asks the user to enter three numbers (integres). A menu will...

    Write a C program that asks the user to enter three numbers (integres). A menu will be displayed to let the user choose one of the three options: print the two highest numbers, product of the three numbers or the division of the second by the by the third if the third is not zero. See the sample runs. Required: Your code must use -One function to get the numbers from the user One function for each of the three...

  • In this assignment we are asking the user to enter two number values, the starting and...

    In this assignment we are asking the user to enter two number values, the starting and ending numbers for our application. Having these values, we then construct a loop that will increment by one (1) from the starting number through (and including) the ending number. Within this loop we will check the current value of our number to see if it is evenly divisible by 3, then by 5, and then by both 3 and 5. We will output all...

  • Write a C code using switch statement that will ask the user to enter a character....

    Write a C code using switch statement that will ask the user to enter a character. This character should be one of the first three characters of your name. The code then should check for the value of the character and output the following: If the character is the same as yo&r first letter then output "X=10" If the character is the same as your second letter then output "Y=5" If the character is the same as your Third letter...

  • C++ programming write a program that asks a user to enter a random IP number (IP...

    C++ programming write a program that asks a user to enter a random IP number (IP number is nothing but 4 numbers with dots in between and each number is between 0 and 255) (example: 1.2.3.4 or 255.255.255.255) The program you will write (Write the program with string function) checks the entered number for 1) making sure each part is between 0 and 255 (if it's 256 or more, it's going to print a message saying one of the values...

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
ADVERTISEMENT