Java How To Program (Early Objects)
10th Edition
ISBN: 9780133807943
Author: Deitel, Paul
Publisher: Pearson Education
expand_more
expand_more
format_list_bulleted
Textbook Question
thumb_up100%
Chapter 4, Problem 16.1E
What does the following
- 1. // Exercise 4.25: Mystery2.java
- 2. public class Mystery2 {
- 3. public static void main(String[] args) {
- 4. int count = 1;
- 3. public static void main(String[] args) {
- 5.
- 6. while (count <= 10) {
- 7. System.out.println(count % 2 == 1
- 8. ++count;
- 9. }
- 6. while (count <= 10) {
- 10. }
- 11. }
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Remaining Time: 1 hour, 28 minutes, 35 seconds.
* Question Completion Status:
QUESTTON 11
There are five syntax errors in the following java program. Explain them by mentioning the line number with
each error.
public class
public static void main (String [] args) {
{
double a = 9;
4
double b = 9.0;
int x;
System.out.println ("Sum of a and b is
if( a = b)
+ (a+b))
80
X = a;
switch (a+b) {
case 0: System.out.println (x);
default: System.out.println (x) ;
10
11
12
13
14
class Variables { public static void main(String[] args) { .
Follow these steps:
Open the Java file Errors.java.
Attempt to compile the program. You'll notice the compilation will fail due
to some errors. Fix all the compilation errors and compile the program
again. Every time you fix an error, add a comment to the line you fixed and
indicate which of the three types of errors it was.
Now run the program. Once again, you'll encounter some errors (this time,
runtime errors). Fix these errors and run the program once again to see if
it works.
Now run the program and notice the output. You'll notice that there are
some logical errors in the code. Fix these errors and run the program once
again to see if it now correctly displays what it should.
Chapter 4 Solutions
Java How To Program (Early Objects)
Ch. 4 - Fill in the blanks in each of the following...Ch. 4 - Fill in the blanks in each of the following...Ch. 4 - Fill in the blanks in each of the following...Ch. 4 - Fill in the blanks in each of the following...Ch. 4 - Prob. 1.5SRECh. 4 - Fill in the blanks in each of the following...Ch. 4 - Prob. 1.7SRECh. 4 - Fill in the blanks in each of the following...Ch. 4 - State whether each of the following is true or...Ch. 4 - State whether each of the following is true or...
Ch. 4 - State whether each of the following is true or...Ch. 4 - State whether each of the following is true or...Ch. 4 - State whether each of the following is true or...Ch. 4 - Prob. 2.6SRECh. 4 - State whether each of the following is true or...Ch. 4 - Prob. 2.8SRECh. 4 - State whether each of the following is true or...Ch. 4 - State whether each of the following is true or...Ch. 4 - Write four different Java statements that each add...Ch. 4 - Write Java statements to accomplish each of the...Ch. 4 - Write Java statements to accomplish each of the...Ch. 4 - Write Java statements to accomplish each of the...Ch. 4 - Write Java statements to accomplish each of the...Ch. 4 - Write a Java statement to accomplish each of the...Ch. 4 - Write a Java statement to accomplish each of the...Ch. 4 - Write a Java statement to accomplish each of the...Ch. 4 - Write a Java statement to accomplish each of the...Ch. 4 - Combine the statements that you wrote in Exercise...Ch. 4 - Determine the value of the variables in the...Ch. 4 - Identify and correct the errors in each of the...Ch. 4 - What is wrong with the following while statement?...Ch. 4 - Compare and contrast the if single-selection...Ch. 4 - Explain what happens when a Java program attempts...Ch. 4 - Describe the two ways in which control statements...Ch. 4 - What type of iteration would be appropriate for...Ch. 4 - What is the difference between preincrementing and...Ch. 4 - Prob. 6.1ECh. 4 - What does the following program print? 1. //...Ch. 4 - 1. Read the problem statement. 2. Formulate the...Ch. 4 - 1. Read the problem statement. 2. Formulate the...Ch. 4 - 1. Read the problem statement. 2. Formulate the...Ch. 4 - 1. Read the problem statement. 2. Formulate the...Ch. 4 - (Find the Largest Number) The process of finding...Ch. 4 - Prob. 13.1ECh. 4 - (Find the Two Largest Numbers) Using an approach...Ch. 4 - Prob. 15.1ECh. 4 - What does the following program print? 1. //...Ch. 4 - What does the following program print? 1. //...Ch. 4 - (Dangling-else Problem) The Java compiler always...Ch. 4 - (Another Dangling-else Problem) Based on the...Ch. 4 - (Another Dangling-else Problem) Based on the...Ch. 4 - Prob. 21.1ECh. 4 - (Palindromes) A palindrome is a sequence of...Ch. 4 - (Printing the Decimal Equivalent of a Binary...Ch. 4 - (Checkerboard Pattern of Asterisks) Write an...Ch. 4 - (Multiples of 2 with an Infinite Loop) Write an...Ch. 4 - (Whats Wrong with This Code?) What is wrong with...Ch. 4 - Prob. 27.1ECh. 4 - Prob. 28.1ECh. 4 - Write an application that estimates the value of...Ch. 4 - Write an application that computes the value of e...Ch. 4 - (Enforcing Privacy with Cryptography) The...Ch. 4 - (World Population Growth) World population has...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
The ____________ is always transparent.
Web Development and Design Foundations with HTML5 (8th Edition)
What will the following program display? public class Checkpoint { public static void main (String [] args) { i...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
The spreadsheet in Microsoft Excel file Ch01Ex01_U10e.xlsx contains records of employee activity on special pro...
Using MIS (10th Edition)
In this chapter, we have introduced some functions with, unsual call and return behaviors longjmp, execve, and ...
Computer Systems: A Programmer's Perspective (3rd Edition)
What characteristic of Rubys arithmetic operators makes them unique among those of other languages?
Concepts of Programming Languages (11th Edition)
Explain the modulo operator. You may need to consult more resources (online Java language resources, other Java...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
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
- use javaarrow_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_forwardpublic static class Lab2{public static void Main(){int idNum;double payRate, hours, grossPay;string firstName, lastName;// prompt the user to enter employee's first nameConsole.Write("Enter employee's first name => ");firstName = Console.ReadLine();// prompt the user to enter employee's last nameConsole.Write("Enter employee's last name => ");lastName = Console.ReadLine()// prompt the user to enter a six digit employee numberConsole.Write("Enter a six digit employee's ID => ");idNum = Convert.ToInt32(Console.ReadLine());// prompt the user to enter the number of hours employeeworkedConsole.Write("Enter the number of hours employee worked =>");// prompt the user to enter the employee's hourly pay rateconsole.Write("Enter employee's hourly pay rate: ");payRate = Convert.ToDouble(Console.ReadLine());// calculate gross paygrossPay = hours * payRate;// output resultsConsole.WriteLine("Employee {0} {1}, (ID: {2}) earned {3}",firstName, lastName, idNum,…arrow_forward
- public class Errors{public static void main (String[] args){System.out.println("Welcome to my first program!\n")String ageStr = "24 years";int age = Integer.parseInt(ageStr);System.out.println("I'm " + age + " years old.");int three = "3";int answerYears = age + three;System.out.println("Total number of years: " + answerYears);int answerMonths = answerYears * 12; System.out.println("In 3 years and 6 months, I'll be " + answerMonths + " months old");//Once you've corrected all the errors, the answer should be 330.}}arrow_forwardUrgent Answer Pleasearrow_forwardmport java.util.Scanner; public class ParkingCharges { // function to calculate the basic charge using the asked hours static double getBasicCharge(int hours) { if (hours >= 7 && hours <= 8) return 5.50; else if (hours >= 5 && hours <= 6) return 4.50; else if (hours >= 2 && hours <= 4) return 4.00; return 3.00; } // function to return the amount to subtract based on local living and OAP static double getDiscount(String isLocal, String isOAP) { if (isOAP.equals("Yes") && isLocal.equals("Yes")) return 2.0 + 1.0; else if (isOAP.equals("Yes")) return 2.0; else if (isLocal.equals("Yes")) return 1.0; return 0; } public static void main(String[] args) { // create a new Scanner object Scanner sc = new Scanner(System.in); // prompt the user to ask if they are disabled…arrow_forward
- public class Test { } public static void main(String[] args){ int a = 10; System.out.println(a*a--); }arrow_forwardpublic class Turn{public static void main(String[] args){// Different initial values will be used for testingint x = 1; int y = 1; // Turn the arrow by 90 degrees System.out.print("x:", y + 90);System.out.println(x);System.out.print("y: ", x - 1 );System.out.println(y); // Turn the arrow again System.out.print("x:", y - 1);System.out.println(x);System.out.print("y: ",x + 90);System.out.println(y);}}arrow_forwardFix all logic and syntax errors. Results Circle statistics area is 498.75924968391547 diameter is 25.2 // Some circle statistics public class DebugFour2 { public static void main(String args[]) { double radius = 12.6; System.out.println("Circle statistics"); double area = java.Math.PI * radius * radius; System.out.println("area is " + area); double diameter = 2 - radius; System.out.println("diameter is + diameter); } }arrow_forward
- // ArtShow.java - This program determines if an art show attendee gets a 5% discount // for preregistering. // Input: Interactive. // Output: A statement telling the user if they get a discount or no discount. import java.util.Scanner; public class ArtShow { public static void main(String args[]) { Scanner s = new Scanner(System.in); String registerString; System.out.println("Did you preregister? Enter Y or N: "); registerString = s.nextLine(); // Test input here. If Y, call discount(), else call noDiscount(). System.exit(0); } // End of main() method. // Write discount method here. // Write noDiscount method here. } // End of ArtShow class.arrow_forwardclass main { public static void main(String args[]) { int x =2; int y =0; for(; y <10;++y) { if(y % x ==0) continue; elseif(y ==8) break; else System.out.print(y +" "); } } } Give result for the code Java Try to do ASAParrow_forwardQuestion 3 4. public class Main { public static void main(String[] args) { int result = sum(10, 10); System.out.println(result); public static int sum(int start, int end) { if (end > start) { return end + sum(start, end - } else { 1); return end; } Blank 1 Blank 1 Add your answerarrow_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
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY