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

CMSC 131 quiz 2(Accurately solved)

Rating
-
Sold
-
Pages
4
Grade
A+
Uploaded on
28-05-2024
Written in
2023/2024

What are the three logical operators? correct answers &&, ||, ! Write "truth-tables" for && and ||. correct answers A B A && B A || B -------------------------------------------------- T T T T T F F T F T F T F F F F Is the following boolean expression true or false?((3 < 5) && !(1 > 14) && (-5 < -15)) || ((6 == 6) && !(2 == 2)) correct answers False If s1 and s2 are variables representing Strings, what Java boolean expression is equivalent to "s1 is not the same as s2"? correct answers !s(s2) What statement must be included at the top of a file in order to use the Scanner in the file? correct answers import .Scanner; Write a java class called "UserInput". In the main method, declare three variables: an int, a float, and a String. Name the variables "age", "weight", and "name". Create a variable called "scan" of type Scanner, and set it equal to a new Scanner. (Use the syntax shown in class). Prompt the user to enter his/her age, weight, and name, then read these entries in using the scanner and set the variables accordingly. Then print the values of the three variables with appropriate labels. For example: "Name: Frank Age: 17 weight: 151.4". correct answers import .Scanner; public class UserInput { public static void main(String[] args) { int age; float weight; String name; Scanner scan = new Scanner(S); S("Enter your age: "); age = Int(); S("Enter your weight: "); Weight = Float(); S("Enter your name: "); name = (); Sln("Name: " + name + ", age: " + age + ", weight: " + weight); } } Write a java class called "FahrenheitToCelcius". The main method will ask the user to enter a temperature in Fahrenheit. (Use a variable of type "double" to store the value.) Then calculate the equivalent temperature in Celcius, and print out a message telling the user what you found. [Recall: C = (5/9)(F-32).] Hint: Be careful about doing arithmetic with integers! Check your program by entering 212 degrees. The output should be 100. correct answers import .Scanner; public class FahrenheitToCelcius { public static void main(String[] args) { Scanner scanner = new Scanner(S); Sln("Enter temp (F): "); double fahrenheit = Double(); double celcius = 5.0/9.0 * (fahrenheit - 32); Sln("That is " + celcius + " degrees C."); } } Modify the "FahrenheitToCelcius" question in the previous question so that the user can either go from F to C or vice versa. correct answers import .Scanner; public class FahrenheitToCelcius { public static void main(String[] args) { Scanner scanner = new Scanner(S); S("Enter 1 to go from F to C; 2 for C to F: "); int response = Int(); if (response == 1) { S("Enter temp (F): "); double fahrenheit = Double(); double celcius = 5.0/9.0 * (fahrenheit - 32); Sln("That is " + celcius + " degrees C."); } else { S("Enter

Show more Read less
Institution
CMSC 131
Course
CMSC 131








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

Written for

Institution
CMSC 131
Course
CMSC 131

Document information

Uploaded on
May 28, 2024
Number of pages
4
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

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.
Insightfulsh3rry NURSING, ECONOMICS, MATHEMATICS, BIOLOGY, AND HISTORY MATERIALS BEST TUTORING, HOMEWORK HELP, EXAMS, TESTS, AND STUDY GUIDE MATERIALS WITH GUARANTEED A+ I am a dedicated medical practitioner with diverse knowledge in matters
View profile
Follow You need to be logged in order to follow users or courses
Sold
18
Member since
2 year
Number of followers
6
Documents
3781
Last sold
4 weeks ago
Insightful Academy.

On this page,we offer a wide selection of revised study materials that guarantee success in your studies and different courses,latest exam updates,assignments,questions and solved answers you will find them all here. For more inquiries dont hesitate to contact us for assistance! Leave us a review after purchase so we can understand our clients . Wishing you all the best in your studies.

3.5

2 reviews

5
0
4
1
3
1
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

Frequently asked questions