Starting Out with Java: Early Objects (6th Edition)
Starting Out with Java: Early Objects (6th Edition)
6th Edition
ISBN: 9780134462011
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 4.5, Problem 4.15CP

The following program is used in a bookstore to determine how many discount coupons a customer gets. Complete the table that appears after the program.

import javax.swing.JOptionPane;

public class Checkpoint

{

 public static void main(String[] args)

 {

 int books, coupons;

 String input;

 input = JOptionPane.showInputDialog(“How many books ” +“are being purchased? ”);

 books = Integer.parseInt(input);

 if (books < 1)

  coupons = 0;

 else if (books < 3)

  coupons = 1;

 else if (books < 5)

  coupons = 2;

 else

  coupons = 3;

 JOptionPane.showMessageDialog(null, “The number of coupons to give is ” + coupons);

 System.exit(0);

}

}

If the customer purchases this many books … this many coupons are given.
1 _____
2 _____
3 _____
4 _____
5 _____
10 _____
Blurred answer
Students have asked these similar questions
// DebugFive2.java // Decides if two numbers are evenly divisible import java.util.Scanner; public class DebugFive2 { publicstaticvoidmain(Stringargs[]) { int num; int num2; Scanner input =newScanner(System.in); System.out.print("Enter a number "); num = input.nextInteger() System.out.print("Enter another number "); num2 = inputnextInt(); if((num % num2 ==0) && (num2 % num) ==0) System.out.println("One of these numbers is evenly divisible into the other"); else System.out.println("Neither of these numbers is evenly divisible into the other"); } }
public void foo4() { String s2 = "smith"; String s3 = s2; String s4 = null; String s5 = ""; String só = new String(s2); if(s2 == s3) { System.out.print("1"); } if(s2.equals(s3)) { System.out.print("2"); } if(s2 == s6) { System.out.print("3"); } if(s2.equals(s6)) { System.out.print("4"); } if(s5 == s4) { System.out.print("5"); } if(s4.equals(s5)) { System.out.print("6"); } 3//end of foo4() Examine and trace the method foo4() above, which statement IS true? O The method will print out "356" on screen. The method will print out "1234" on screen. The method will print out "123" on screen. The method will print out "124" on screen.
public String getJoblitle() { return joblitle; 11 12 13 44 45 46 47 48 49 50 public void setJoblitle(String joblitle) { this.jobTitle - joblitle; public int getCurrentEmploynent() { return currentEmploynent; 1. public void selCurrentEnployent (int current Fmployment) { this.currentEmploynent - currentEmployment; 53 54 55 56 -57 goverride public String tostring () { return "CurrentEmploynentStatsclass [areaName=" + arealame + 58 + "year=" + year + ", jobtitle-" + joblitle , currentEnploynent-" + currenttmployment + "]": 59 61 62 63 64 } What algorithm does this method perform? public statie Currentiploynentstatsclass mysteryethod (CurrentEmploynentstatsclass] array) ( int holder = array[0).getCurrenttmploynent(); Currenttmploynentstatsclass variable = array[®]; for(int i- 0, i holder) { holder = holderx; variable - array[1]; return variable; 36. What is the above method returning? 37. What is the Big O time of the above method?

Chapter 4 Solutions

Starting Out with Java: Early Objects (6th Edition)

Ch. 4.2 - Write an if-else statement that assigns 0 to the...Ch. 4.4 - Write nested if statements that perform the...Ch. 4.4 - Write code that tests the variable x to determine...Ch. 4.5 - What will the following program display? public...Ch. 4.5 - The following program is used in a bookstore to...Ch. 4.6 - Prob. 4.16CPCh. 4.6 - Assume the variables a = 2, b = 4, and c = 6....Ch. 4.6 - Write an if statement that displays the message...Ch. 4.6 - Write an if statement that displays the message...Ch. 4.7 - Assume the variable name references a String...Ch. 4.7 - Prob. 4.21CPCh. 4.7 - Prob. 4.22CPCh. 4.9 - Rewrite the following if-else statements as...Ch. 4.10 - Complete the following program skeleton by writing...Ch. 4.10 - Rewrite the following if-else-if statement as a...Ch. 4.10 - Explain why you cannot convert the following...Ch. 4.10 - What is wrong with the following switch statement?...Ch. 4.10 - What will the following code display? int funny =...Ch. 4 - The if statement is an example of a __________. a....Ch. 4 - This type of expression has a value of either true...Ch. 4 - , , and = = are __________. a. relational...Ch. 4 - , | |, and ! are __________. a. relational...Ch. 4 - Prob. 5MCCh. 4 - To create a block of statements, you enclose the...Ch. 4 - This is a boolean variable that signals when some...Ch. 4 - How does the character A compare to the character...Ch. 4 - This is an if statement that appears inside...Ch. 4 - Prob. 10MCCh. 4 - When determining whether a number is inside a...Ch. 4 - Prob. 12MCCh. 4 - The conditional operator takes this many operands....Ch. 4 - This section of a switch statement is branched to...Ch. 4 - True or False: The = operator and the == operator...Ch. 4 - True or False: A conditionally executed statement...Ch. 4 - Prob. 17TFCh. 4 - True or False: When an if statement is nested in...Ch. 4 - True or False: When an if statement is nested in...Ch. 4 - True or False: The scope of a variable is limited...Ch. 4 - Find the errors in the following code: 1. //...Ch. 4 - Find the errors in the following code: 2. //...Ch. 4 - Find the errors in the following code: 3. //...Ch. 4 - Prob. 4FTECh. 4 - Find the errors in the following code: 5. The...Ch. 4 - Find the errors in the following code: 6. The...Ch. 4 - The following statement should determine whether...Ch. 4 - Find the errors in the following code: 8. The...Ch. 4 - Prob. 9FTECh. 4 - Write an if statement that assigns 100 to x when y...Ch. 4 - Write an if-else statement that assigns 0 to x...Ch. 4 - Using the following chart, write an if-else-if...Ch. 4 - Write an if statement that sets the variable hours...Ch. 4 - Write nested if statements that perform the...Ch. 4 - Write an if statement that prints the message The...Ch. 4 - Write an if statement that prints the message The...Ch. 4 - Write an if statement that prints the message The...Ch. 4 - Write an if-else statement that displays the...Ch. 4 - Convert the following if-else-if statement into a...Ch. 4 - Match the conditional expression with the if-else...Ch. 4 - Explain what is meant by the phrase conditionally...Ch. 4 - Explain why a misplaced semicolon can cause an if...Ch. 4 - Why is it good advice to indent all the statements...Ch. 4 - What happens when you compare two String objects...Ch. 4 - Prob. 5SACh. 4 - What risk does a programmer take when not placing...Ch. 4 - Prob. 7SACh. 4 - Prob. 8SACh. 4 - Why are the relational operators called...Ch. 4 - How do you use private methods in a class to...Ch. 4 - Roman Numerals Write a program that prompts the...Ch. 4 - Time Calculator Write a program that asks the user...Ch. 4 - TestScores Class Design a TestScores class that...Ch. 4 - Software Sales A software company sells a package...Ch. 4 - BankCharges Class A bank charges 10 per month,...Ch. 4 - ShippingCharges Class The Fast Freight Shipping...Ch. 4 - FatGram Class Design a class with a method that...Ch. 4 - Running the Race Write a program that asks for the...Ch. 4 - The Speed of Sound The following table shows the...Ch. 4 - Freezing and Boiling Points The following table...Ch. 4 - Mobile Service Provider A mobile phone service...Ch. 4 - Mobile Service Provider, Part 2 Modify the program...Ch. 4 - Body Mass Index Write a program that calculates...Ch. 4 - Days in a Month Write a class named MonthDays. The...Ch. 4 - Book Club Points Serendipity Booksellers has a...Ch. 4 - Magic Dates The date June 10, 1960, is special...Ch. 4 - Hot Dog Cookout Calculator Assume that hot dogs...Ch. 4 - Roulette Wheel Colors On a roulette wheel, the...Ch. 4 - Wi-Fi Diagnostic Tree Figure 3-23 shows a...Ch. 4 - Restaurant Selector You have a group of friends...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Look at the second constructor in C1ockDisplay's source code. Explain what it does and how it does it.

Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)

Why should you indent the statements in the body of a loop?

Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)

Carpet Calculator The Westfield Carpet Company has asked you to write an application that calculates the price ...

Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)

Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY