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 11E
Write a switch statement to convert a letter grade into an equivalent numeric value on a four-point scale. Set the value of the variable gradeValue to 4.0 for an A, 3.0 for a B, 2.0 for a C, 1.0 for a D, and 0.0 for an F. For any other letter, set the value to 0.0 and display an error message.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that asks the user to enter a number within the range of 1 through 10. Use a switch statement to display the Roman numeral version of that number.
Input Validation: Decide how the program should handle an input that is less than 1 or greater than 10.
In the
postincrement; the value is incremented
by 1 and use the new value in the next
expression in which it resides.
Select one:
True
O False
Write a switch statement that displays Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, if day is 0, 1, 2, 3, 4, 5, 6, respectively.
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
What is the difference between an object and a class?
Computer Science: An Overview (12th Edition)
Write a variable declaration for an Integer variable named intUnitsSold.
Starting Out With Visual Basic (8th Edition)
The spreadsheet in Microsoft Excel file Ch01Ex01_U10e.xlsx contains records of employee activity on special pro...
Using MIS (10th Edition)
Why is it necessary to introduce some methods and documentation from plan-based approaches when scaling agile m...
Software Engineering (10th Edition)
What is a symbol table?
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
What is the difference between a protected class member and a private class member?
Starting Out with Java: From Control Structures through Data Structures (4th 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
- 3. Draw flowchart to calculate the value of y depending on the given value of x as shown below: if x> 0 y= 3x+2 if X<= 0 y= 3x-2arrow_forwardManually trace the code fragment provided above. What string would be printed to the terminal if the character 'h' was provided as user input? This question is internally recognized as variant 241. Q16) 1-6-7-8- 0-2-5-6- 1-4-5-7-8- 0-3-4-8- 0-8- 4-5-7-8- 0-1-3-4- 1-2-4-5-6-8- none of the abovearrow_forwardWrite some simple code that can display a grade in a message box, given the marks through a textbox txtTest, using the following grading system. Use Select..Case. Marks Grade 0 - 49 Fail, 50 - 64 Pass, 65 - 74 Credit, 75 - 100 Distinction, Any other Invalidarrow_forward
- . It must be determined whether the beach is to be closed or not. Right after the average has been output, you will need an if statement to decide whether the beach is to be closed or not. If the average is below 3500 print out the beach number and a short message that the beach is safe; if greater than or equal to 3500 print out the beach number and a short message that the beach is closed. , add a report to count the total number of beaches in the file and how many are open, and how many are closed. //include the required header file. #include "stdio.h" //Define the main function. int main(void) { //Declare the variable. int b_num, num_samples, num_orgs_per_100; char c = 'a'; //Create a file pointer. FILE *in_file; //Open the file in read mode. in_file = fopen("inp.txt", "r"); //Check if the file exists. if (in_file == NULL) printf("Error opening the file.\n"); //Read the data from the file. else { //Get the…arrow_forwardEvaluate the following expression. Give the final value of x. Your answer is either a 1 or a 0 if the answer is a true or a false. x = 'a'> 'b' && 'c' == 'C'arrow_forward.Draw a flowchart that will read and print the names and individual score of 50 students for a particular examination. Also, determine the average score and print it.arrow_forward
- I keep running this code as seen in the first picture and it keep giving me this error message seen in the second picture and I don't understand why. the initial question is: Allow a user to enter any number of double values up to 15. The user should enter 99999 to quit entering numbers. Display an error message if the user quits without entering any numbers; otherwise, display each entered value and its distance from the average. if that helpsarrow_forwardQ4. Answer the following: 1.Write MATLAB commands to calculate the area of the triangle shown in the figure below. Y axis P3(2,3) P:(1,1) P2(3,1) X axis 2. Write an if statement that would print "No overtime for you!" if the value of a variable hour is greater than 2. Test the if statement for values of hours both less than and greater than 2.arrow_forwardGiven a character variable named ch, write a switch statement that prints out the word “winner” if the value of ch is ‘w’, the words “first place” if the value of ch is ‘f’, the words “second place”, if the value of ch is ‘s’, the words ”third place” if the value if ch is ‘t’, and the words “honorable mention” if the value of ch is anything else.arrow_forward
- Can provide a description outlining which option chosen and a description of how the code works and how to use it. Also can you fix the code. #Defining AND circuit def AND(a, b): #If both values are 1 return 1 if a == 1 and b == 1: return 1 else: #Otherwise return 0 return 0 #Defining OR circuit def OR(a, b): #If either of value is 1 return 1 if a + b == 1 or a == b == 1: return 1 else: #Otherwise return 0 return 0 #Defining NOT circuit def NOT(a): #If the input is 1 if a == 1: #Return 0 return 0 #If the input is 0 elif a == 0: #Return 1 return 1 #Defining NAND circuit def NAND(a, b): a = AND(a, b) if a == 1: return 0 else: return 1 #Defining NOR circuit def NOR(a, b): a = OR(a, b) if a == 1: return 0 else: return 1 #Defining XOR circuit def XOR(a, b): a = OR(AND(a, NOT(b)), AND(NOT(a), b)) if a == 1: return a else: return 0 #Defining NXOR circuit def…arrow_forwardDraw a flowchart that will print numbers from 1 to 8 and get the sum of these 8numbers.arrow_forwardmodify it based on the instructions below: -clicking a to add the amount (which shouldn't be displayed before pressing a, it should just have the info), -clicking b which will modify only the last name to uppercase (the first and last name are already uppercase before I press b which shouldn't be happening, and 'b' is used for another feature not just changing it to uppercase) maybe use an if statement and ask the user if they want to change it to uppercase for the first or last name, or -increase the hourly rate by 10 for comp sci majors. -clicking b should also add 10 to the hourly rate for computer science majors when updating data so if you could implement that please -the last thing is when clicking c, you should be able to insert a new node to the sequence with the amount calculated and display it, make it so the user can enter In the new node and have it displayed. please do it in a timely manner code below #include <bits/stdc++.h>using namespace std; struct…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Linux - Tutorial for Beginners in 13 MINUTES! [ UPDATED ]; Author: bai;https://www.youtube.com/watch?v=BMGixkvJ-6w;License: Standard YouTube License, CC-BY
What is Linux?; Author: Techquickie;https://www.youtube.com/watch?v=zA3vmx0GaO8;License: Standard YouTube License, CC-BY
Introduction to Linux and Basic Linux Commands for Beginners; Author: sakitech;https://www.youtube.com/watch?v=IVquJh3DXUA;License: Standard Youtube License