Just wanted to compare & see if the answers I wrote are done correctly: 1. Write
ID: 3552991 • Letter: J
Question
Just wanted to compare & see if the answers I wrote are done correctly:
1. Write a function prototype for a function that will accept a payrate as a reference parameter and a percent raise (ie: 2.5) as a value parameter. It's purpose is to calculate a new payrate based on the percent raise.
2. Write the function definition for a function that will prompt and read input from the user for a room's length and width. The function is of type void.
3. Write the code that will read character input from the user until a '?' is entered. Print how many characters were entered before the '?'
(Keep in mind the user may decide tgo enter a '?' as his/her first character.)
4. Write the code to prompt and read positive integer values from the user until he/she decides to quit by entering a non-positive interger. The code should print the maximum number the user entered.
5. Write a do-while loop to read and validate an employee's salary. The minimum salary the company pays is $12,000 and the maximum salary the company pays is $75,000
6. Suppose the following definitions are in effect
bool P= false;
bool Q=true;
bool R=true;
int i=1;
int j=0;
e. P && (Q || R)
f. !!P
7. Write a do-while loop to read and validate user input for a menu. The only valid input is 'A', 'B' or 'C'
8. Write the code to read an validate user input for an item at the Family Dollar store. The only valid prices are in the range of 1 to 15 (inclusive) [1,15] (do-while loop)
Explanation / Answer
1.void newPayrate(double &payrate, double per_raise);
2.void read(){
int length,breadth;
cout << "Enter length of room : ";
cin >> length;
cout << "entre thr breadth of room : ";
cin >> breadth;
}
3.count = 0;
cout << "Enter a character('? ' to stop ) :" ;
cin >> charac;
while(charac != '?'){
count++;
cout << "Enter a character('? ' to stop ) :" ;
cin >> charac;
}
cout << count;
4.max = 0;
cout << "Enter a number (negative number to quit) :";
cin >> number;
while(number >=0){
if(number > max){
max = number;
}
cout << "Enter a number (negative number to quit) :";
cin >> number;
}
cout << max;
5.input =1;
do{
cout << "enter your salary : ";
cin >> salary;
if(salary > 12000 && salary < 75000){
cout << "valid salary";
}else{
cout << "Invalid slaray";
}
cout << "Enter 1 for more input anything else to quit : ";
cin >> input;
}while(input == 1);
6.e = p && (Q || R)
e = false && true
e = false
f.!!P
!!(false)
!true
false
7.do{
cout << "Enter a charcter";
cin >> input;
}while(input == 'A' || input == 'B' || input == 'C');
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.