100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

CMSC 140 midterm Questions and Answers(A+ Solution guide)

Rating
-
Sold
-
Pages
6
Grade
A+
Uploaded on
11-12-2024
Written in
2024/2025

Code the following statements using combined assignment operators: 1. price1 is equal to price1 plus 5. 2. price2 is equal to price2 times 7.0 3. price3 is equal to price3 divided by 4.5 4. totalPrice is equal to totalPrice modulus 3 Hint: Things like an equal sign or multiply sign but initialize the variables. - ️️double price1 = 3.45, price2 = 5.79, price3 = 15.64; int totalPrice = 98; //1. price1 += 5; //2. price2 *= 7.0; //3. price3 /= 4.5; //4. totalPrice %= 3;

Show more Read less
Institution
CMSC 140
Course
CMSC 140









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
CMSC 140
Course
CMSC 140

Document information

Uploaded on
December 11, 2024
Number of pages
6
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

CMSC 140 midterm
Code the following statements using combined assignment operators:
1. price1 is equal to price1 plus 5.
2. price2 is equal to price2 times 7.0
3. price3 is equal to price3 divided by 4.5
4. totalPrice is equal to totalPrice modulus 3

Hint: Things like an equal sign or multiply sign but initialize the variables. - ✔️✔️double
price1 = 3.45, price2 = 5.79, price3 = 15.64;
int totalPrice = 98;

//1.
price1 += 5;
//2.
price2 *= 7.0;
//3.
price3 /= 4.5;
//4.
totalPrice %= 3;

What does the following code output to the user?


int A = 10, B = 17, C = 2;
double D = 17.01;
bool boolValue = true;

if (A > B)
{
cout << "Good afternoon, sir." << endl;
if (A == C)
{
cout << "Fine weather today we're having." << endl;
}
}
else if (D < B)
{
cout << "It looks like it will rain later on." << endl;
}
else
{
cout << "Good morning." << endl;

, if (boolValue == true)
{
cout << "The sun's bright at this time." << endl;
}
else
{
cout << "We've got a lot of cloud cover now." << endl;
}
} - ✔️✔️//The code outputs:
//Good morning.
//The sun's bright at this time.

What does the following code ouput to the user?

int num1 = 10, num2 = 13, num3 = 10, square, quotient;
bool firstBool = true;
bool secondBool = false;

if (firstBool && num2 < num3)
{
cout << "Good day!" << endl;
if (firstBool && !(secondBool))
{
cout << "Fine weather this morning." << endl;
}
else
{
cout << "The weather's a bit muggy, isn't it?" << endl;
}
}
else if (!firstBool || !secondBool)
{
cout << "Hello!" << endl;
if (firstBool && (secondBool == false))
{
cout << "Top of the morning to you!" << endl;
}
if (num1 == num3)
{
cout << "The sun is shining bright today." << endl;
}
else
{
cout << "It's a bit chilly out, don't you think?" << endl;
}
}

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
PatrickKaylian Delaware State University
View profile
Follow You need to be logged in order to follow users or courses
Sold
1808
Member since
2 year
Number of followers
1043
Documents
22126
Last sold
18 hours ago

3.8

316 reviews

5
147
4
60
3
54
2
15
1
40

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions