Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

COMP 150 WEEK 3 DISCUSSION 2024 LATEST SPRING-SUMMER SESSION

Rating
-
Sold
-
Pages
9
Grade
A+
Uploaded on
16-11-2024
Written in
2024/2025

COMP 150 WEEK 3 DISCUSSION 2024 LATEST SPRING-SUMMER SESSION

Institution
Course

Content preview

COMP 150 WEEK 3 DISCUSSION 2024 LATEST SPRING-
SUMMER SESSION
Write an expression that evaluates to true if and only if the integer x is greater than
the integer y. - ANSWER: x>y

Given an int variable grossPay, write an expression that evaluates to true if and only
if the value of grossPay is less than 10,000. - ANSWER: grossPay < 10000

Write an expression that evaluates to true if and only if the value of the integer
variable x is equal to zero. - ANSWER: x==0

Write an expression that evaluates to true if and only if the variables profits and
losses are exactly equal . - ANSWER: profits==losses

Given the char variable c, write an expression that is true if and only if the value of c
is not the space character . - ANSWER: c!=' '

Write an expression that evaluates to true if the value of index is greater than the
value of lastIndex. - ANSWER: index > lastIndex

Working overtime is defined as having worked more than 40 hours during the week.
Given the variable hoursWorked, write an expression that evaluates to true if the
employee worked overtime. - ANSWER: hoursWorked > 40

Write an expression that evaluates to true if the value x is greater than or equal to y.
- ANSWER: x>=y

Given the variables numberOfMen and numberOfWomen, write an expression that
evaluates to true if the number of men is greater than or equal to the number of
women. - ANSWER: numberOfMen>=numberOfWomen

Given a double variable called average, write an expression that is true if and only if
the variable 's value is less than 60.0. - ANSWER: average<60

Write an expression that evaluates to true if the value of the integer variable x is
divisible (with no remainder) by the integer variable y. (Assume that y is not zero.) -
ANSWER: x % y==0

Write an expression that evaluates to true if and only if the integer variable
numberOfShares is less than 100. - ANSWER: numberOfShares < 100

Write an expression that evaluates to true if and only if the value of the boolean
variable workedOvertime is true . - ANSWER: workedOvertime==true

, Assume that a bool variable isQuadrilateral has been declared , and that an int
variable , numberOfSides has been declared and initialized . Write a statement that
assigns the value of isQuadrilateral to true if numberOfSides is exactly 4 and false
otherwise. - ANSWER: isQuadrilateral = numberOfSides==4;

Assume that a bool variable workedOvertime has been declared , and that an int
variable hoursWorked has been declared and initialized . Write a statement that
assigns the value of workedOvertime to true if hoursWorked is greater than 40 and
false otherwise. - ANSWER: workedOvertime= hoursWorked > 40;

Write an expression that evaluates to true if the value of the integer variable
numberOfPrizes is divisible (with no remainder) by the integer variable
numberOfParticipants. (Assume that numberOfParticipants is not zero.) - ANSWER:
numberOfPrizes%numberOfParticipants==0

Write a conditional that assigns 10,000 to the variable bonus if the value of the
variable goodsSold is greater than 500,000. - ANSWER: if(goodsSold>500000)
bonus=10000;

Write a conditional that decreases the variable shelfLife by 4 if the variable
outsideTemperature is greater than 90. - ANSWER: if(outsideTemperature>90)
shelfLife-=4;

Assume that the variables gpa, deansList and studentName, have been declared and
initialized . Write a statement that both adds 1 to deansList and prints studentName
to standard out if gpa exceeds 3.5. - ANSWER: if (gpa > 3.5)
{
deansList++;
cout << studentName;
}

Assume that isIsosceles is a bool variable , and that the variables isoCount,
triangleCount, and polygonCount have all been declared and initialized . Write a
statement that adds 1 to each of these count variables (isoCount, triangleCount, and
polygonCount) if isIsosceles is true . - ANSWER: if (isIsosceles == true)
{
isoCount += 1;
triangleCount += 1;
polygonCount += 1;
}

Write an if/else statement that compares the variable age with 65, adds 1 to the
variable seniorCitizens if age is greater than or equal to 65, and adds 1 to the
variable nonSeniors otherwise. - ANSWER: if (age>=65)
seniorCitizens++;
else
nonSeniors++;

Connected book

Written for

Course

Document information

Uploaded on
November 16, 2024
Number of pages
9
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$18.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
THEPROJECTOR

Also available in package deal

Get to know the seller

Seller avatar
THEPROJECTOR Teachme2-tutor
Follow You need to be logged in order to follow users or courses
Sold
7
Member since
1 year
Number of followers
1
Documents
1137
Last sold
3 weeks ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions