What will the following program display?
public class Checkpoint
{
public static void main (String [] args)
{
int funny = 7, serious = 15;
funny = serious % 2;
if (funny != 1)
{
funny = 0;
serious = 0;
}
else if (funny == 2)
{
funny = 10;
serious = 10;
}
else
{
funny = 1;
serious = 1;
}
System.out.println(funny + ” ” + serious};
}
}
Trending nowThis is a popular solution!
Learn your wayIncludes step-by-step video
Chapter 3 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out With Visual Basic (8th Edition)
Modern Database Management
SURVEY OF OPERATING SYSTEMS
Introduction To Programming Using Visual Basic (11th Edition)
Elementary Surveying: An Introduction To Geomatics (15th Edition)
- 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_forwardpublic class Test { } public static void main(String[] args) { int a = 5; a += 5; } switch(a) { case 5: } System.out.print("5"); break; case 10: System.out.print("10"); System.out.print("0"); default:arrow_forwardpublic class MysteryReturn2 {3 public static void main(String[] args)4 {5 int x = 1;6 int y = 2;7 int z = 3;89 z = mystery(x, z, y);10 System.out.println(x + " " + y + " " + z);11 }1213 public static int mystery(int c, a, int b);14 {15 c--;16 a = 2 * b + c;17 b = a - 1;18 System.out.println(b + " " + c);1920 return a;21 }22 } 1. Line 13 contains 2 errors. What are they? 2. Rewrite line 13 with the errors identifed in Question 1 corrected.arrow_forward
- public class MysteryReturn2 {3 public static void main(String[] args)4 {5 int x = 1;6 int y = 2;7 int z = 3;89 z = mystery(x, z, y);10 System.out.println(x + " " + y + " " + z);11 }1213 public static int mystery(int c, a, int b);14 {15 c--;16 a = 2 * b + c;17 b = a - 1;18 System.out.println(b + " " + c);1920 return a;21 }22 } 1. The mystery method has three parameter variables, a, b, and c. What is the scope of these variables (that is, where can they be used by their name)?arrow_forwardclass isNaN_output { public static void main(String args[]) { Double d = new Double(1 / 0.); boolean x = d.isNaN(); System.out.print(x); } } What will the given code prints on the output screen.arrow_forwardQ1. amount the same, y, n, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { balance = balance + amount ; } // modified toString() method public String toString() { return "Account: " + actNum + "\tName: " + nameOnAct + "\tBalance: " + amount ; } } Q2. amount the same, y, n, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { // scope of amount starts here balance = balance + amount ; // scope of amount ends here } public void processCheck( int amount ) { // scope of amount starts here int charge; incrementUse(); if ( balance < 100000 ) charge = 15; else charge = 0; balance = balance - amount - charge ; // scope of amount ends here }…arrow_forward
- // This class discounts prices by 10% public class DebugFour4 { public static void main(String args[]) { final double DISCOUNT_RATE = 0.90; int price = 100; double price2 = 100.00; tenPercentOff(price DISCOUNT_RATE); tenPercentOff(price2 DISCOUNT_RATE); } public static void tenPercentOff(int p, final double DISCOUNT_RATE) { double newPrice = p * DISCOUNT_RATE; System.out.println("Ten percent off " + p); System.out.println(" New price is " + newPrice); } public static void tenPercentOff(double p, final double DISCOUNT_RATE) { double newPrice = p * DISCOUNT_RATE; System.out.println"Ten percent off " + p); System.out.println(" New price is " + newprice); } }arrow_forward1 a. is the amount the same, yes or no, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { balance = balance + amount ; } // modified toString() method public String toString() { return "Account: " + actNum + "\tName: " + nameOnAct + "\tBalance: " + amount ; } } b. public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { // scope of amount starts here balance = balance + amount ; // scope of amount ends here } public void processCheck( int amount ) { // scope of amount starts here int charge; incrementUse(); if ( balance < 100000 ) charge = 15; else charge = 0; balance = balance - amount - charge ; // scope of amount ends here } } c. is the…arrow_forwardpublic class Number { private int num; public Number(int n) { num = n; } /* Type your code here */ public int getNum() { return num; } public void setNum(int n) { num = n; } public static void main(String [] args) { Number yourNum = new Number(723); System.out.print(yourNum); }}arrow_forward
- public class Test { } public static void main(String[] args){ int a = 10; System.out.println(a*a--); }arrow_forwardclass class { public static void main(String args[]) { int a =5; int b =10; first: { second: { third: { if(a == b >>1) break second; } System.out.println(a); } System.out.println(b); } } } Give result for the code Java Try to do ASAParrow_forward/* TestCarSensor.java - program to test the CarSensor class.*/public class TestCarSensor{public static void main (String[] args){CarSensor generic = new CarSensor();CarSensor tempCel = new CarSensor("temperature sensor", -50, +300, "C"); CarSensor speed = new CarSensor("speed sensor", 0, 200, "km/h"); CarSensor speed2 = new CarSensor("speed sensor 2", 0, 200, "m/h"); // 2. test changing desc and limitsSystem.out.println ();System.out.println ( generic ); // display generic sensor (zero)generic.setDesc ("special sensor"); // change descriptiongeneric.setLimits (-5,5,"units"); // change limitsSystem.out.println ( generic ); // display generic sensor again// 3. test displaying object (calling .toString() )System.out.println ();System.out.println ( tempCel );System.out.println ( speed );System.out.println ( speed2 );// 4. test setlimits() ruleSystem.out.println ();System.out.println ( generic ); generic.setLimits (10, -10, "blah"); System.out.println ( generic ); generic.setLimits (-10,…arrow_forward
- 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