Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 3, Problem 12E
Consider the previous question, but include + or – letter grades. A+ is 4.25, A– is 3.75, B+ is 3.25. B– is 2.75, and so on.
- a. Why can’t we use one switch statement with no other conditionals to convert these additional letter grades?
- b. Write a fragment of code that will do the conversion using a multibranch if-also statement.
- c. Write a fragment of code that will do the conversion using nested switch statements.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Implement the following questions using Python. Make use of conditional and print statements.Make sure to clearly define your variables and don’t forget to indent your code.
The logician Raymond Smulyan describes an island containing two types of people:knights who always tell the truth and knaves who always lie. You visit the island and are approached bytwo natives who speak to you as follows:• A says: B is a knight.• B says: A and I are of opposite type.What are A and B?
2. How do you use "else if" and "else"?
4. Write a program which to find the grace marks for a student using switch. The
user should enter the class obtained by the student and the number of subjects he
has failed in.
- If the student gets first class and the number of subjects he failed in is greater
than 3, then he does not get any grace. If the number of subjects he failed in is
less than or equal to 3 then the grace is of 5 marks per subject.
- If the student gets second class and the number of subjects he failed in is greater
than 2, then he does not get any grace. If the number of subjects he failed in is
less than or equal to 2 then the grace is of 4 marks per subject.
- If the student gets third class and the number of subjects he failed in is greater
than 1, then he does not get any grace. If the number of subjects he failed in is
equal to 1 then the grace is of 5 marks per subject.
[Marks - 10]
Chapter 3 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 3.1 - Suppose goals is a variable of type int. Write an...Ch. 3.1 - Suppose goals and errors are variables of type...Ch. 3.1 - Suppose salary and deductions are variables of...Ch. 3.1 - Suppose speed and visibility are variables of type...Ch. 3.1 - Suppose salary and bonus are variables of type...Ch. 3.1 - Assume that nextWord is a string variable that has...Ch. 3.1 - Prob. 7STQCh. 3.1 - What output is produced by the following code? int...Ch. 3.1 - Suppose you change the code in the previous...Ch. 3.1 - What output is produced by the following code? int...
Ch. 3.2 - Suppose number is a variable of type int that has...Ch. 3.2 - What output is produced by the following...Ch. 3.2 - What output is produced by the following...Ch. 3.2 - What output is produced by the following...Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - Suppose you change the code in the previous...Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - Suppose you change the first line of the code in...Ch. 3.3 - Prob. 20STQCh. 3.4 - Suppose you change the order of the drawing...Ch. 3.4 - Prob. 22STQCh. 3.4 - Write code for a JOptionPane dialog that will ask...Ch. 3 - Write a fragment of code that will test whether an...Ch. 3 - Write a fragment of code that will change the...Ch. 3 - Suppose you are writing a program that asks the...Ch. 3 - Prob. 4ECh. 3 - Consider the following fragment of code: What is...Ch. 3 - We would like to assess a service charge for...Ch. 3 - What is the value of each of the following boolean...Ch. 3 - The following code fragment will not compile. Why?...Ch. 3 - Prob. 9ECh. 3 - Consider the boolean expression (2 5) (x 100))....Ch. 3 - Write a switch statement to convert a letter grade...Ch. 3 - Consider the previous question, but include + or ...Ch. 3 - Imagine a program that displays a menu of five...Ch. 3 - Repeat the previous exercise, but define an...Ch. 3 - Repeat Exercise 13, but use a multibranch if-else...Ch. 3 - Given that the int variable temp contains a...Ch. 3 - Write Java statements that create a yes-or-no...Ch. 3 - A number x is divisible by y if the remainder...Ch. 3 - Write a program to read in three nonnegative...Ch. 3 - Write a program that reads three strings from the...Ch. 3 - Write a program that reads a one-line sentence as...Ch. 3 - Write a program that allows the user to convert a...Ch. 3 - Write a program that inputs an integer. If the...Ch. 3 - Prob. 7PCh. 3 - Repeat Programming Project 5 of Chapter 2, but...Ch. 3 - Repeat any of the previous Practice Programs using...Ch. 3 - Suppose that we are working for an online service...Ch. 3 - Write a program that reads a string from the...Ch. 3 - Repeat the calorie-counting program described in...Ch. 3 - Repeat Programming Project 5 but in addition ask...Ch. 3 - Repeat Programming Project 11 in Chapter 2, but if...Ch. 3 - Write a program to play the rock-paper-scissor...Ch. 3 - Prob. 9PPCh. 3 - Repeat Programming Project 8 in Chapter 1, but add...Ch. 3 - Write a program that inputs two strings that...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Does the While loop test its condition before or after it performs an iteration?
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
Broaching machines are simpler in a basic design than most other machine tools. Why is this?
Degarmo's Materials And Processes In Manufacturing
In each case, express the shear and moment functions In terms of x, and then draw the shear and moment diagrams...
Mechanics of Materials (10th Edition)
Days in a Month Write a class named MonthDays, The classs constructor should accept two arguments: An integer f...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
If the Vole executes an instruction every microsecond (a millionth of a second), how long does it take to compl...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Question 1: As you are a student of university now, you need to ensure your assignments are plagiarism-free. To do this, you decide to design a simple plagiarism checker. Your checker will take 2 strings as input. Then it will compare the 2 strings and check how many words they have in common. Then, print the percentage in common, by calculating: (No. of words in common / (No of words in string 1+ No of words in string 2)) * 100. If the calculated plagiarism is greater than or equal to 30%, print "Plagiarism detected." Otherwise, print "Good job!". Note: you need to compare "words" not individual characters. You can consider that all characters in both inputs will be in only lowercase or uppercase. ========= ======== Sample Input 1: my dog's name is bob bob is my dog's name Sample Output 1: Common percentage: 50% Plagiarism detected. Explanation 1: Length of string1= 5, Length of string2= 5, number of common words= 5. Hence, common percentage= (5/(5+5))*100 = 50 %3D Sample Input 2: my…arrow_forward3, A lecturer intends to separate his students into 2 groups based on their INDEX Numbers, those with odd numbers in group A and EVEN numbers in B. Use if-else statement to implement thisarrow_forwardJust answer it directly wihtout explaing. Thank You.arrow_forward
- Take an Infix expression from the user and convert into postfix. 1. Should be self-organizing program e.g. If the user enters two operators back to back by mistake. The program should automatically delete one of the 2 operators. 2. If the user doesn't enter a multiplication sign before a bracket, the program should automatically insert a multiplication sign there.arrow_forwardYOU SHOULD NOT USE LOOPS (for, while,….) OR CONDITIONALS (if..else,….),For this question, you should use Math function for doing the “power” and “π”. When printingthe volume and the area values, DON’T ENTER THEM MANUALLY. Only print 2 numbers after the decimal points.arrow_forwardI need the answer as soon as possiblearrow_forward
- I need the answer as soon as possiblearrow_forwardkindly change the program following the procedure on the problem. please list the changes you have made on the program t..thank youarrow_forwarddefinitely pick 2 coins and win. If there are 3 coins and Alice is still the first player to pick, the game. For example, if there are 2 coins and Alice is the fitst player to pick, she will no matter she picks I or 2 coins, Bob will get the last coin and win the game. Given number of coins and the order of plavers (which means the first and the second players pick the coins), you are required to write a program to calculate the winner of the ga and calculate how many different strategies there are for heishe to win the game. should use recursion to solve the problem, and the parameters are read from the commnana line. You can assume that there are no more than 30 coinarrow_forward
- hi! i am a newbie in python. please help me on this problem. also, please send a screenshot for a proof that the codes works. thanks~arrow_forward(This is for devc++ but I use mindmap from Cengage. I know it a little different. If you can't use Cengage, I suggest devc++ version 5.11) One way to determine how healthy a person is, is by measuring the body fat of the person. The formulas to determine the body fat for female and male are as follows: Body fat formula for women: A1 = (body weight X 0.732) + 8.987 A2 = wrist measurement (at fullest point) / 3.140 A3 = waist measurement (at navel) X 0.157 A4 = hip measurement (at fullest point) X 0.249 A5 = forearm measurement (at fullest point) X 0.434 B = A1 + A2 - A3 - A4 + A5 Body fat = body weight - B Body fat percentage = body fat X 100 / body weight Body fat formula for men: A1 = (body weight X 1.082) + 94.42 A2 = waist measurement X 4.15 B = A1 - A2 Body fat = body weight - B Body fat percentage = body fat X 100 / body weight Instructions Write a program to calculate the body fat of a person. Prompt the user to input: Their gender ('m' or 'M' for male, 'f' or 'F' for…arrow_forwardUsing Eclipse: Implement a program that directs a cashier how to give change. The program has two inputs: the amount due and the amount received from the customer. Display the dollars, quarters, dimes, nickels, and pennies that the customer should receive in return. In order to avoid roundoff errors, the program user should supply both amounts in pennies, for example 274 instead of 2.74. Use labels for each currency when you display.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY