[solved] – Question 99410

Type a statement using srand() to seed random number generation using variable seedVal. Then type two statements using rand() to print two random integers between (and including) 0 and 9. End with a newline. Ex:
5
7
Note: For this activity, using one statement may yield different output (due to the compiler calling rand() in a different order). Use two statements for this activity. Also, after calling srand() once, do not call srand() again.

Expert Answer


[solved] – Question 99411

Type two statements that use rand() to print 2 random integers between (and including) 100 and 149. End with a newline. Ex:
101
133
Note: For this activity, using one statement may yield different output (due to the compiler calling rand() in a different order). Use two statements for this activity. Also, srand() has already been called; do not call srand() again.

Expert Answer


[solved] – Question 99412

Write a statement that increases numPeople by 5. Ex: If numPeople is initially 10, the output is: There are 15 people.

Expert Answer


[solved] – Question 99413

Write an expression that will cause the following code to print “greater than 20” if the value of userAge is greater than 20.

Expert Answer


[solved] – Question 99414

Write an if-else statement for the following:

If userTickets is greater than 8, execute awardPoints = 10. Else, execute awardPoints = userTickets.

Ex: If userTickets is 14, then awardPoints = 10.

Expert Answer


[solved] – Question 99415

Re-type the code and fix any errors. The code should convert non-positive numbers to 1.
if (userNum > 0)
cout << “Positive.” << endl;
else
cout << “Not positive, converting to 1.” << endl;
userNum = 1;

cout << “Final: ” << userNum << endl;

Expert Answer


[solved] – Question 99416

Write multiple if statements:
If carYear is before 1968, print “Probably has few safety features.” (without quotes).
If after 1971, print “Probably has head rests.”.
If after 1990, print “Probably has anti-lock brakes.”.
If after 2002, print “Probably has tire-pressure monitor.”.
End each phrase with period and newline. Ex: carYear = 1995 prints:
Probably has head rests.
Probably has anti-lock brakes.

Expert Answer


[solved] – Question 99417

Write an expression that will cause “Foot or more” to print if the value of numInches is greater than or equal to 12.

#include <iostream>
using namespace std;

int main() {
int userNum;

cin >> userNum; // Program will be tested with values: 1, 2, 3, 4.

if (userNum = 2) {
cout << “Num is less or equal to two” << endl;
}
else {
cout << “Num is greater than two” << endl;
}

return 0;
}

Expert Answer


[solved] – Question 99418

Write an if-else statement that checks patronAge. If 55 or greater, print “Senior citizen”, otherwise print “Not senior citizen” (without quotes). End with newline.

#include <iostream>
using namespace std;

int main() {
int patronAge;

cin >> patronAge;

/* Your solution goes here */

return 0;
}

Expert Answer


[solved] – Question 99419

Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print “Distant future” (without quotes). Else, if givenYear is 2001 or greater (2001-2100), print “21st century”. Else, if givenYear is 1901 or greater (1901-2000), print “20th century”. Else (1900 or earlier), print “Long ago”. Do NOT end with newline.

#include <iostream>
using namespace std;

int main() {
int givenYear;

cin >> givenYear;

/* Your solution goes here */

return 0;
}

Expert Answer