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
Document preview thumbnail
Preview 2 out of 10 pages
Exam (elaborations)

CSC 110 Assignment 3 (2.9-2.15 and 3.1-3.2) EXAM QUESTIONS WITH CORRECT ANSWERS.

Document preview thumbnail
Preview 2 out of 10 pages

CSC 110 Assignment 3 (2.9-2.15 and 3.1-3.2) EXAM QUESTIONS WITH CORRECT ANSWERS.8. Cookie Calories A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 servings in the bag and that a serving equals 300 calories. Write a program that lets the user enter the number of cookies he or she actually ate and then reports the number of total calories consumed. - CORRECT ANSWERpackage javacookies; import .Scanner; public class JavaCookies { public static void main(String[] args) { int cookieCount; Scanner keyboard = new Scanner(S); Sln("Enter number of cookies eaten:"); cookieCount = Int(); int servingSize = 40/10; double caloriesPerCookie = 300/servingSize;

Content preview

CSC 110 Assignment 3 (2.9-2.15 and 3.1-3.2) EXAM
QUESTIONS WITH CORRECT ANSWERS.

8. Cookie Calories

A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are

10 servings in the bag and that a serving equals 300 calories. Write a program that lets the

user enter the number of cookies he or she actually ate and then reports the number of total

calories consumed. - CORRECT ANSWER✅✅package javacookies;




import java.util.Scanner;

public class JavaCookies {



public static void main(String[] args) {



int cookieCount;

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter number of cookies eaten:");

cookieCount = keyboard.nextInt();



int servingSize = 40/10;

double caloriesPerCookie = 300/servingSize;

double totalCalories = cookieCount * caloriesPerCookie;



System.out.println("Your calorie intake was: " + totalCalories

+ " calories");



}

, }



A comment starts with what characters? - CORRECT ANSWER✅✅//



Assume that a boolean variable isQuadrilateral has been declared, and that another variable,
numberOfSides has been declared and initialized. Write a statement that assigns the value true if
numberOfSides is exactly 4 and false otherwise. - CORRECT ANSWER✅✅if(numberOfSides==4)

isQuadrilateral = true;

else

isQuadrilateral = false;



Assume that a boolean variable workedOvertime has been declared, and that another variable,
hoursWorked has been declared and initialized. Write a statement that assigns the value true to
workedOvertime if hoursWorked is greater than 40 and false otherwise. - CORRECT
ANSWER✅✅if(hoursWorked > 40)

workedOvertime = true;

else

workedOvertime = false;



Assume that c is a char variable has been declared and already given a value. Write an expression whose
value is true if and only if c is a newline character. - CORRECT ANSWER✅✅c == '\n'



Assume that c is a char variable has been declared and already given a value. Write an expression whose
value is true if and only if c is a tab character. - CORRECT ANSWER✅✅c == '\t'



Assume that isIsosceles is a boolean 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, andpolygonCount) if isIsosceles is true. - CORRECT
ANSWER✅✅if(isIsosceles == true)

{

isoCount +=1;

triangleCount +=1;

Document information

Study
Uploaded on
November 30, 2025
Number of pages
10
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$12.19

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

Sold
1
Followers
0
Items
934
Last sold
9 months ago



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