OO T-Mobile 11:17 AM 95% occ blackboard com 2 of 4 Part A Write a new class name
ID: 3814141 • Letter: O
Question
OO T-Mobile 11:17 AM 95% occ blackboard com 2 of 4 Part A Write a new class named PartA and implement the following main method 1. Declare an int variable named multiplyBy Request user input between land 10 and assign itte the ant variable vou declared in step 1 don't forget an itorilelse for range checking) 3, write a loop that wiltake and create a multiplication table that wiltake the number the user entered and multiply that number from to 12. 7, write a Do/WHILI loop that will a. Ask the user to enter anumber(positive or negativel and wilassign itto b Accumulate the servalueinto sumvalue exit the WHILE loop 8, Display the value of (temsin red were entered by the user) 1 and 10: 1 Enter a positive integer or 0 to quit Enter a positive nteger or 0 Enter a positive integer or 0 to quit Rnter a positive integer or 0 to between 1 and 10 Enter a positive integer or 0 to quit: 2 D to quit positive integer or to quit: Enter a positive nteger or 0 to quit Enter a positive nteger or 0 to qukt Enter a positive knteger or 0 to Enter a positive integer or 0 to quitExplanation / Answer
#include <iostream>
using namespace std;
class partA{
public: int multiplyBy;
};
int main()
{
partA p;
int n;
int userValue=0,sumValue=0;
cout<<"Enter a number between 1 and 10: ";
cin>>p.multiplyBy;
if(p.multiplyBy<1 || p.multiplyBy>10)
{cout<"Invaid Input range";}
else{
for(n=1;n<=12;n++)
cout << p.multiplyBy<< " * " << n << " = " << n * p.multiplyBy << endl;
cout<<" ";
do{
cout<<"Enter a positive integer or 0 to quit: ";
cin>>userValue;
sumValue=sumValue+userValue;
}while(userValue!=0);
cout<<" Sum is:"<<sumValue;
}
return 0;
}
#include <iostream>
using namespace std;
class partB{
public: int a,b,c,high;
};
int main()
{
partB p;
int goldilocks;
char ans='y';
cout<<"Enter three distinct positive integers >0: ";
cin>>p.a>>p.b>>p.c;
if(p.a<0 || p.b<0||p.c<0)
{cout<"Error!! Invalid Input range";}
else{
if(p.a >= p.b && p.a >= p.c)
{
cout << "Largest number: " << p.a;
}
if(p.b >= p.a && p.b >= p.c)
{
cout << "Largest number: " << p.b;
}
if(p.c >= p.a && p.c >= p.b) {
cout << "Largest number: " << p.c;
}
}
do{
cout<<" Enter a number between 1 and 5: ";
cin>>goldilocks;
switch(goldilocks){
case 1 :
case 2 :
cout<<"Too low ";
break;
case 4 :
case 5 :
cout<<"Too high ";
break;
case 3:
cout<<"The value is just right ";
break;
default:
cout<<"Error !Enter between 1 and 5";
break;
}
cout<<"Try aigian??[y or n]: ";
cin>>ans;
}while(ans!='n'||ans!='N');
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.