Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 3, Problem 10STE
Explanation of Solution
Given: The following code:
int key = 1;
switch (key + 1)
{
case 1:
System.out.println("Apples");
break;
case 2:
System.out.println("Oranges");
break;
case 3:
System.out.println("Peaches");
case 4:
System.out.println("Plums");
break;
default:
System.out.println("Fruitless");
}
To find:Â The output of the code:
int key = 1;
switch (key + 1)
{
case 1:
System.out.println("Apples");
break;
case 2:
System.out.println("Oranges");
break;
case 3:
System.out.println("Peaches");
case 4:
System...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
22. What is the value of x after the following statements are executed? int x = 5; switch(x) { case 5: x += 2; case 6: x++; break; default: x *= 2; break; }
int test(int *x, int y){
x=&y;
return(*x+y);
}
int main(void) {
int x=1, y=6;
test(&y, x);
printf("%d %d %d", x, test (&y,x),y);
return 0;
}
1 2 6
q1
please fast
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
- 9. What will the following print out? = 0; int num System.out.println("Song titles with numbers include: "); switch (num) { case 12: System.out.println("12 days of Christmas"); case 99: System.out.println("99 bottles of beer on the wall"); System.out.println("99 Luftballons"); case 7: System.out.println("7 Chinese Brothers"); case 50: System.out.println("50 Mission Cap"); default: System.out..println ("If I had a million dollars"); А. Song titles with numbers include: 7 Chinese Brothers 50 Mission Cap If I had a million dollars В. Song titles with numbers include: 7 Chinese Brothers С. Song titles with numbers include: 12 Days of Christmas 99 bottles of beer on the wall 99 LuftBallons 7 Chinese Brothers D. Song titles with numbers include: If I had a million dollarsarrow_forwardAnalyze the following code: int x = 0;if (x > 0) ;{System.out.println(x);} The code has syntax error. The code has run time error. The value of variable x is always printed because the print statement is not controlled by the if condition. Nothing is printed because x > 0 is false if x = 0.arrow_forwardString number = “1”; switch ( number ) { case 1: System.out.println( "The number is 1" ); break; case 2: System.out.println( "The number is 2" ); break; default: System.out.println( "The number is not 1 or 2" ); break; } correct the above code.arrow_forward
- With the statement, With the statement, int option=1; switch(option){ int a=1; case 1: printf("1"); while(a<=10){ case 2: printf("2"); With the statement, a++; case 3: printf("3"); break; int x=0; a++; while(x!=20) { printf("%d", a); default: printf("“4"); x+=2; a++; } a+t; } What is the output of the given code? How many times this code will loop? What is the output? 357 syntax error О 123 infinite loop 159 10 5913 12 O 11 3711 O run time errorarrow_forwardint main(){ if(var1>50) { num = 20.0 } else { if(var1>35) ---- Line 7 { num= 35.0; } else if (var1<80) { num=60.0; } else { num=40.0; }} What should be the outcome of the condition in line 7 in order for the value of num to be equal to 60.0?arrow_forward#include main() {int=a, b=2, x=0, x=a + b * a + 10/2 * a, printf("value is =%d", x);} What is the value?arrow_forward
- 4. How many times the statement "Statement" is printed in the following code? void fun(int R) { printf("Statement"); if(R <= 1) return; fun(R / 3); } void main( ) { fun(R); }arrow_forwardа. int GreaterThan(int no) { if (no > 10) printf("%d is greater than 10", no); else printf("%d is less than 10", no); }arrow_forwardint a = 10, b =7; System.out.println(a>b?a:b); Will always print what?arrow_forward
- Urgent Answer Pleasearrow_forwardWhat does the following code display: int value = 41; System.out.printin ( "Incrementing value: " if( value == 41 ) { System.out.println ( "Something went wrong with the increment : ("); }else if ( value == 42 ) { System.out.println ( "Ah, the answer to life the universe and everything :) ") : }else if ( value == 43 ) { System.out.println ( "Weird, really weird 8) "); + value++ ); Incrementing value: 41 Something went wrong with the increment :( Incrementing value: 41 Ah, the answer to life the universe and everything :) Incrementing value: 42 Ah, the answer to life the universe and everything :) Incrementing value: 42 Weird, really weird 8)arrow_forwardQuestion public class MyProgram { if (h 18) { public static void main(String[] args) { int h=10, t-22; System.out.print ("Good "); } } else } } What is the output displayed by the following lines of code?" System.out.print ("Morning"); t = t + 2; if (t > 30) System.out.println(" Every one!"); System.out.println("The Your answer system.out.print("Evening"); t = t + 5; temperature is " System.out.println(" Brink water?"); Degree.");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