Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 3, Problem 12STE
Program Plan Intro
To modify a
Program Plan:
Write a code in Java and get the result when the first line of the code is replaced by “int key = 5;� in the following original program:
int key = 1;
switch (key + 1)
{
case 1:
System.out.printIn("Apples");
break;
case 2:
System.out.printIn("Oranges");
break;
case 3:
System.out.println("Peaches");
case 4;
System.out.println("Plums");
break;
default;
System.out.println("Fruitless");
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
what is the output of the following code fragment?
int x =10;
if (x > 15)
x =0;
System.out.println(x);elseSystem.out.println(x+5);
What is wrong with the following code? How would you fix it?
public static returnTrue(boolean b){ if (b){ return true; } else { return true; }}
What is the output by the following printf()?
int i =1, j = 2;
i += ++j + i-- * 5/2;
printf("%d", j );
Chapter 3 Solutions
Absolute Java (6th Edition)
Ch. 3 - Write an if-else statement that outputs the word...Ch. 3 - Suppose savings and expenses are variables of type...Ch. 3 - Suppose number is a variable of type int. Write an...Ch. 3 - Suppose salary and deductions are variables of...Ch. 3 - What output will be produced by the following...Ch. 3 - What would be the output in Self-Test Exercise 5...Ch. 3 - What would be the output in Self-Test Exercise 5...Ch. 3 - Write a multiway if-else statement that classifies...Ch. 3 - Prob. 9STECh. 3 - Prob. 10STE
Ch. 3 - Prob. 11STECh. 3 - Prob. 12STECh. 3 - Prob. 13STECh. 3 - Suppose are two variables that have been given...Ch. 3 - Prob. 15STECh. 3 - Assume that nextword is a String variable that has...Ch. 3 - Write an if-else statement that outputs the word...Ch. 3 - Write an if-else statement that outputs the word...Ch. 3 - Determine the value, true or false, of each of the...Ch. 3 - Does the following sequence produce a division by...Ch. 3 - Prob. 21STECh. 3 - Prob. 22STECh. 3 - What output would be produced in Self-Test...Ch. 3 - What is the output produced by the following?
Ch. 3 - What output would be produced in Self-Test...Ch. 3 - Prob. 26STECh. 3 - What is the most important difference between a...Ch. 3 - Prob. 28STECh. 3 - Prob. 29STECh. 3 - What is the output of the following?
Ch. 3 - Rewrite the following for statement as a while...Ch. 3 - What is the output of the following loop? Identify...Ch. 3 - What is the output of the following loop? Comment...Ch. 3 - Prob. 34STECh. 3 - For each of the following situations, tell which...Ch. 3 - What is the output of the following?
Ch. 3 - What is the output of the following?
Ch. 3 - What is the output produced by the following?...Ch. 3 - What is the output produced by the following?...Ch. 3 - Fix the bug in the code in the earlier subsection...Ch. 3 - Add some suitable output statements to the...Ch. 3 - What is the bug in the following code? What do you...Ch. 3 - Prob. 43STECh. 3 - What numbers could be generated by...Ch. 3 - What numbers could be generated by...Ch. 3 - Use the method Math. random to generate a random...Ch. 3 - (This is a version of Programming Project 2.1 from...Ch. 3 - A designer is trying to create a new pattern of...Ch. 3 - Weight is defined as the gravitational force...Ch. 3 - It is difficult to make a budget that spans...Ch. 3 - You have just purchased a stereo system that cost ...Ch. 3 - The Fibonacci numbers Fn are defined as follows:...Ch. 3 - An Armstrong number is an n-digit number that...Ch. 3 - In a certain code language, numerals are each...Ch. 3 - Write a program that calculates the total grade...Ch. 3 - The game of Pig is a simple two-player dice game...Ch. 3 - You have three identical prizes to give away and a...Ch. 3 - Redo or do for the first time Programming Project...Ch. 3 - The file words. txt on the hook's website contains...Ch. 3 - The file words. txt on the book's website contains...Ch. 3 - This problem is based on a "Nifty Assignment" by...Ch. 3 - Prob. 16PP
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
- How many times will the following code will print "Final Test"? three times none one time four timesarrow_forwardWhat would happen if you tried to execute the program after adding the following code before “return 0;” How could you fix it? Please describe it by words. Int*v=&t; Printf(“%d\n”,*v); Int*varrow_forwardWhat is the printout of the following code? x = 1 def f1(): x=3 print(x) f1() print(x)arrow_forward
- What are the values of X[i] and X[i+1] after code corresponding to the following code is run? int X[5]; int i=0; int A = 100, B = 200, C = 300; X[i] = A; X[i+1] = B; C = X[i]; X[i] = X[i+1]; X[i+1]= C;arrow_forwardWhat is the output produced by the following?String test = "abcdefg";System.out.println(test.length());System.out.println(test.charAt(1));arrow_forwardWhat is the output produced by the following lines of program code?int n = (int)3.9;System.out.println("n == " + n);arrow_forward
- What is the output of the following code? Is there a relationship between the variables x and y? If yes, state the relationship? What is the output?int x = 19683;int i;int y = 0;for (i = x; i >= 1; i = i / 3)y++;cout << "x = " << x << ", y = " << y << endl;arrow_forwardtrace the following code and give the output. for (int k=5; k<=20; k+=5) cout << "? ";arrow_forwardSuppose you change the code in the previous question so that the first line is the following: int time = 4, tide = 3; What output would be produced?arrow_forward
- Consider the following code: public static void test_b(int n) { if (n>0) test_b(n-2); System.out.println(n + " "); } What is printed by the call test_b(6)?arrow_forwardTHIS IS IN JAVA Given x = 1, y = 2, and z = 3, how is the expression evaluated? In the choices, items in parentheses are evaluated first. <pre><code>(x == 5) || (y == 2) && (z == 5)</code></pre> A. false OR (true AND false) --> false OR false --> false B. false OR (true AND false) --> false OR true --> true C. (false OR true) AND false --> true AND false --> false D. (false OR true) AND false --> true AND false --> truearrow_forwardWhat is the output of the following code fragment? int a = 10, b = 3; boolean answer = ((--a >= 10) && (--b == 20)); System.out.println(a + "," + b + "," + answer);arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,