c++ Write a program that asks the user for a number between 1 and 30, then displ
ID: 3573383 • Letter: C
Question
c++
Write a program that asks the user for a number between 1 and 30, then displays the following message based on the table below. Note that you should only have one output per run (in the order of priority shown in the table).
Examples:
Please enter a number between 1 and 30:2
Adam
Please enter a number between 1 and 30: 3
Debbie
Please enter a number between 1 and 30: 15
Charlie
Please enter a number between 1 and 30: 1
No category
If the number is Less than 1 Between 1 and 19 (inclusive) Between 18 and 30 (inclusive) Between 9 and 22 (inclusive) Between 3 and 29 (inclusive) Over 30 Not in any of the above categories And Even Or Even Or Even And Odd Display: low Adam Betty Charlie Debbie Too high No categoryExplanation / Answer
#include<iostream>
using namespace std;
main()
{
int num;
cout<<"enter a number 1 and 30:";
cin>>num;
if(num<1)
cout<<"Too low";
else if(num>=1 && num<=19 && (num%2==0))
cout<<"Adam";
else if(num>=18 && num<=30 || (num%2==0))
cout<<"Betty";
else if(num>=9 && num<=22 || (num%2==0))
cout<<"Charlie";
else if(num>=3 && num<=22 && (num%2==1))
cout<<"Debbie";
else if(num>30)
cout<<"Too high";
else
cout<<"No category!";
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.