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 | _____ |
Trending nowThis is a popular solution!
Chapter 3 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects (9th Edition)
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Degarmo's Materials And Processes In Manufacturing
SURVEY OF OPERATING SYSTEMS
Mechanics of Materials (10th Edition)
Electric Circuits. (11th Edition)
- public class Course{String name;String dept;int number;public Course (String n, String d, int n){name = n;dept = d;number = n;}public String toString(){return "Course " + name + " in " + dept + " #: " + number;}public static void main (String [] args){Scanner in = new Scanner(System.in);add 10 lines using the scanner and saving them as strings The input for each line will be entered a String, a space, another String, and an int. Parse the input string into those three items and make an instance of Course. Add the new Course instance to a generic ArrayList of Course. print out each Course in the ArrayList.arrow_forwardInstructions Insurance.java >- Terminal + 1 import java.util.Scanner; sandbox $ 0 2 class Insurance { The Harrison Group Life Insurance company computes public static void main (String args[]) { // Write your code here annual policy premiums based on the age the customer 4 turns in the current calendar year. The premium is } computed by taking the decade of the customer's age, adding 15 to it, and multiplying by 20. 7 public static int calculatePremium(int curr, int birth) { 8 // Write your code here } For example, a 34-year-old would pay $360, which is calculated by adding the decades (3) to 15, and then 10 } 11 multiplying by 20. Write an application that prompts a user for the current year then a birth year. Pass both to a method that calculates and returns the premium amount, and then display the returned amount. An example of the program is shown below: Enter the current year >> 2020 Enter the birth year >> 2001 The premium is $320 Grading Write your Java code in the area on the…arrow_forwardusing System; class main { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { int i; Random r = new Random(); int[] randNo=newint[3]; for(i=0;i<3;i++) { randNo[i]= r.Next(1,88); Console.WriteLine("Random Number between 1 and 88 is "+randNo[i]); } } } } This code is supposed to count from 1-88 and then select three random numbers from the list but instead it generates an infinite loop of random numers between 1-88. how can it be fixed?arrow_forward
- using System; class main { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { int i; Random r = new Random(); int[] randNo=newint[3]; for(i=0;i<3;i++) { randNo[i]= r.Next(1,88); Console.WriteLine("Random Number between 1 and 88 is "+randNo[i]); } } } } how can this program be fixed to count from 1-88 and then choose 3 different random numbers?arrow_forward// Displays five random numbers between // (and including) user-specified values import java.util.Scanner; public class DebugSix4 { publicstaticvoidmain(String[] args) { int high, low, count =0; finalint NUM =5; Scanner input =newScanner(System.in); System.out.print("This application displays " + NUM + " random numbers"+ "\nbetween the low and high values you enter"+ "\nEnter low value now... "); low = input.nextInt() System.out.print("Enter high value... "); high = inputnextInt(); while(low < high) { System.out.println("The number you entered for a high number, " + high + ", is not more than " + low); System.out.print("Enter a number higher than " + low + "... "); high = input.nextInt(); while(count <NUM) { double result = Math.random(); int answer = (int) (result *10+ low); if(answer <= higher) { System.out.print(answer + " "); ++count; } } System.out.println("End of Application"); } }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
- public class Test { } public static void main(String[] args) { String str = "Salom"; System.out.println(str.indexOf('t)); }arrow_forwardjava language for solution 2. Write math random statement to generate each of the 1. random number between 0 and 1. 2. random number between 2 and 20. 3. random number between 0 and 50. 4. random number between 30 and 100. (1/2 Points) 3. having char c; C = 'a'; The result of isDigit(c) is: * (0.5/0.5 Points) truearrow_forwardclass Exam { public static void main(String[] args) { X x = new X(); System.out.printIn(x.value); } } O a. public O b. private O c. protected O d. None of the abovearrow_forward
- public dlass examplemark public static void main(String args) on float studentmark=(46.56,65.78,89.91,100.00.75.55): studentmark[0]=56.46 system.out.printin"Student Mark"studentmark(0): Identify the mistakes/ errors in the above program and rewrite the full correct statement.arrow_forward// Application allows user to enter a series of words // and displays them in reverse order import java.util.*; public class DebugEight4 { publicstaticvoidmain(String[] args) { Scanner input =newScanner(System.in); int x =0, y; String array[] =newString[100]; String entry; finalString STOP =XXX; StringBuffer message =new StringBuffer("The words in reverse order are\n"); System.out.println("Enter any word\n" + "Enter + STOP + when you want to stop"); entry = input.next(); while(!(entry.equals(STOP))) { array[x] = entry; ++x; System.out.println("Enter another word\n" + "Enter "+STOP+" when you want to stop"); entry = input.next(); } for(y = x -1; y >0; ++y) { message.append(array[y]); message.append("\n"); } System.out.println(message) }arrow_forwardWhat is causing this error?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