Using Math.max and/or Math.min, write a class MaxOrMin, and make sure touse Math.max and Math.min which does the following: a. Create a Scannerb. Declare two variables, number1 and number 2c. Ask the user to enter 2 numbersd. Using the information above, print messages displaying the highest and lowest values ora message if the numbers are equal. The messages should look like the sample outputbelow Tip• Use if-else statement Submission• Copy and paste your code• Screen shot the console with user input of three examples Sample Run Enter a number 5Enter a number 9The lowest value is 5The highest value is 9 Enter a number 24Enter a number 11The lowest value is 11The highest value is 24 Enter a number 12Enter a number 1212 and 12 are equal
Q: Write a class RangeInput that allows users to enter a value within a range of values that is…
A: According to the information given:- we have to follow the instruction to get the desired outcome.…
Q: Write a program with class name PowerOf2 that computes all powers of 2 from 0 up to 20.
A: Since you have not mentioned the programming language in the question, we have used Java programming…
Q: Write a program GuessMyNumber game. When it's finished, it will work like this: I'm thinking of a…
A: Required:
Q: The goal of this program is to input one number consisting of five digits (in one word) from the…
A: To access digits we use logic : while number >= 1 digit = number%10 add digit to…
Q: Implement the design of the Avengers class so that the following output is produced: [You are not…
A: Here I have first of all created the class named Avengers. In this class, I have created a…
Q: Write a class, AgeMessages , which does the following: a. Ask the user to enter age using a Scanner…
A: The if function is one of the logical functions to return one value if a condition is true and…
Q: What is printed by the code below? Note: There are two separate classes here. public class…
A: Answer : The above code is of Java Programming, and we need to find out the output of the given…
Q: Task 6 Implement the design of the Laptop class so that the following output is| produced [You are…
A: Note: - As per the guidelines we can only answer one specific question at a time. Please resubmit…
Q: have no idea what to do. Modify the FitnessTracker class, created in Chapter 4 Programming Exercise…
A: TestFitnessTracker2.java package bartleby; import java.time.*;public class…
Q: public static int myMethod (int testValue){ final int TOP_BOUND = // ... what goes here? final int…
A: I give the code along with output and code screenshot
Q: Implement the design of the Laptop and Store classes so that the following code generates the…
A: Algorithm: Start Create a class Store with laptops a list as static variable and name as instance…
Q: In this exercise you will write a program to compute the distance between any two geo locations. In…
A: we have given GeoLocation class we have to implement its main method which is given below
Q: Create a java class called Question4, and implement the following points inside the main method: 1.…
A:
Q: What is the probability that in a classroom of x people, at least 2 will be born on the same day of…
A: Solution: Probability of having at least two people's birthdays on the same day through simulating…
Q: 1. Write a program that prompts the user to input the height and the radius of the base of a…
A: Program code: //importing required data package import javax.swing.*; //class public class…
Q: I have already written the program and have it right, but I need help write print statement for the…
A: The print statement in java is: System.out.println(); where System is a package name, out is its…
Q: Task 6 Implement the design of the Laptop class so that the following output is produced [You are…
A: Let's understand step by step : 1. lenovo = Laptop("Lenovo",5) So there will be class Laptop whose…
Q: Implement the design of the Travel class in python so that the following output is produced: You…
A: Algorithm: Start Implement class Travel with a static variable count and class variables…
Q: Write a class, NumberToMonth, which does the following:a. Ask the user to enter the month of the…
A: The algorithm for the program would be as below:Declare one int variable for accepting user…
Q: id data is entered. If user enters an invalid data, then appropriate message should be displayed…
A: EXPLANATION Create a simple class student which will have two fields name and marks. Now call…
Q: Implement the design of the Chillox and Customer classes so that the following code generates the…
A: The answer is
Q: Make a new class in the Lab3 project called Primes. Add a method to this class called isprime, which…
A: A number is said to be a prime number if it has only 2 factors 1 and itself So, start counting the…
Q: Task 6 Implement the design of the Laptop class so that the following output is produced [You are…
A: Code:- class Laptop: #declare a class called Laptop laptopCount=0 #initialize laptopCount to…
Q: Write a program in a class contructor and destructor to print two numbers and then find ? the…
A: Note: Here you didn't mention any programming language so we are writing the program in the C++…
Q: Implement the design of the Pizza class so that the following output is produced: # Write your…
A: The Pizza class has four variables to store the data values for the object of the pizza. The three…
Q: Write a program to find the average of three scores. Use one class for each score.
A: Please refer below for your reference: According to question ,I have used a class and a method…
Q: Implement the design of the Spotify class so that the following output is produced: Driver Code…
A: After completing the code, I have provided PYTHON CODE along with CODE SCREENSHOT and…
Q: write a python program : Implement the design of the Chillox and Customer classes so that the…
A: ANSWER: FILENAME: Foodcart.py
Q: 1) Implement the class Doctor: a) The name could be composed from more than one word. b) The…
A: Given, One class doctor. There all are private variables. create some getter and setter method and…
Q: Write a class RangeInput that allows users to enter a value within a range of values that is…
A: CODE TEXT SO YOU DON'T HAVE TO TYPE. public class RangeInput { private int currentValue;…
Q: Write a complete method having the signature myfloor(double value) that can return mathematical…
A: Java Code : //importing package to read input from the user by using scanner classimport…
Q: Write a static method: public static double priceIsRight(Scanner s, double price) that takes a…
A: import java.util.Scanner;class Main{ static double priceIsRight(Scanner s, double price){…
Q: I have this problem and I keep getting a error. "ShoppingCartPrinter.java:29: error: reached end of…
A: Question: I have this problem and I keep getting a error. "ShoppingCartPrinter.java:29: error:…
Q: 1) Implement the class Image: The height, width and size data fields should be positive. The…
A: Java code import java.util.Date; public class Image { //class with all the variables withdefault…
Q: Trace the exact output of the following programs by running them in a java compiler. (ps I don't…
A: 1. Output: redgreen Explanation: In the Apple class, the color variable is set to "red" so when…
Q: Write a program that displays a clock to show the current time, as shown in Figure 9.27a. To obtain…
A: Below is the python code for the same. Please use proper indentation and import the required…
Q: Write a java program which asks the user to enter name and age and calls the following methods: a.…
A: Actually, the answer has given below:
Q: Write a class in java with the name AgeMessages, which does the following: a. Ask the user to enter…
A: INTRODUCTION: In the given code statement, we are asked to create one java class and naming it as…
Q: Create another class DayProg and write the main() method to display the following: Today is…
A: As the language is not specified answer written in python to deal with date and time we need to…
Q: Write a class RangeInput that allows users to enter a value within a range of values that is…
A: Given The answer is given below. CODE:- import java.util.Scanner; class RangeInput { static int…
Q: Po In the space below, write the six lines of output when the following Java code fragment is run.…
A: public class Main{ public static void main(String[] args) {double go= 10;int fight = 20;int win =…
Q: Write a program to test the class LinkedBag. For example create a bag by asking the user for few…
A: In the Main class I created an object of type linkedBag and asked the user to enter names to enter…
Q: Write a program GuessMyNumber game. When it's finished, it will work like this I'm thinking of a…
A: The complete code is given below . Please like , thank you ?
Q: Build a simple lottery program that asks the user to input six numbers, prints those numbers, spins…
A: Build a simple lottery program that asks the user to input six numbers, prints those numbers, spins…
Q: THIS IS MEANT TO BE WRITTEN IN JAVA. The assignment is to get an integer from input, and output…
A: /*Get an integer from input, and output that integer squared, ending with newline.*/ import…
Q: the Card.java class file, write a program to simulate a Deck of Cards. See Programming Project 8.7…
A: It is defined as a class-based object-oriented programming language for building web and desktop…
Q: Write a method that turns some text into something Porky Pig would say. To do that, you just need to…
A: ALGORITHM:- 1. Take input for the string from user. 2. Declare a character array of input string…
Q: Write a Temperature class that will hold a temperature in Fahrenheit, and provide methods to get the…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Write a class, VoteAge, which does the following:a. Ask the user to enter their age (ex. XX)b. Get…
A: The algorithm for the program would be as below:Declare one float variable for accepting user…
Using Math.max and/or Math.min, write a class MaxOrMin, and make sure to
use Math.max and Math.min which does the following:
a. Create a Scanner
b. Declare two variables, number1 and number 2
c. Ask the user to enter 2 numbers
d. Using the information above, print messages displaying the highest and lowest values or
a message if the numbers are equal. The messages should look like the sample output
below
Tip
• Use if-else statement
Submission
• Copy and paste your code
• Screen shot the console with user input of three examples
Sample Run
Enter a number 5
Enter a number 9
The lowest value is 5
The highest value is 9
Enter a number 24
Enter a number 11
The lowest value is 11
The highest value is 24
Enter a number 12
Enter a number 12
12 and 12 are equal
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- Continuing from the example, modify the program so that it outputs the average grade in each course, and also shows which course has the highest average grade. import java.util.Scanner; public class Main { publicstaticvoid main(String[] args) { Scanner s = new Scanner(System.in); int numCourses, numTests; double[][] testScores; System.out.print("How many courses are you taking? "); numCourses = s.nextInt(); testScores = new double[numCourses][]; // allocate an array of references to 1-D arrays (rows) for(int i = 0; i < numCourses; i++) { System.out.print("How many tests are in course number " + (i+1) + "? "); numTests = s.nextInt(); // allocate this row: a 1-D array of doubles: testScores[i] = new double[numTests]; } for(int courseId=0; courseId < testScores.length; courseId++) { for(int testId=0; testId < testScores[courseId].length; testId++) { System.out.print("What was your grade on test " + (testId+1) + " for course " + (courseId+1) + "? ");…Implement the design of the Spotify class so that the following output is produced: Driver Code Output# Write your code hereuser1 = Spotify(["See You Again", "Uptown Funk", "Hello"])print("=========================")print(user1.playing_number(4))user1.add_to_playlist("Dusk Till Dawn")print(user1.playing_number(3))print(user1.playing_number(4)) Welcome to Spotify!=========================4 number song not found. Your playlist has 3 songs only.##########################Playing 3 number song for youSong name: Hello##########################Playing 4 number song for youSong name: Dusk Till Dawnwrite the java mini project and upload the code .class as like this and also provide the screenshot of the code. use these method for insert ,remove and search public boolean insertBook(Book b) { for(int i=0; i<books.length; i++) { if(books[i] == null) { books[i] = b; return true; } } return false; } public boolean removeBook(Book b) { for(int i=0; i<books.length; i++) { if(books[i].getIsbn().equalsIgnoreCase(b.getIsbn())) { for(int j=i; j<books.length-1; j++) { books[j] = books[j+1]; } return true; } } return false; } public Book searchBook(String isbn) { for(int i=0; i<books.length; i++) { if(books[i] != null) {…
- In this exercise, you are going to complete the Rectangle class. You need to complete the class so that you can print and compare two rectangles. Once complete, use the RectangleTester to test the results. In the tester class, you are given 3 rectangles that you should print and compare. Sample results are provided below. Sample output A rectangle with a width of 5 and a height of 4 A rectangle with a width of 5 and a height of 4 A rectangle with a width of 10 and a height of 4 true false =========================================== public class RectangleTester{public static void main(String[] args){Rectangle rect1 = new Rectangle(5, 4);Rectangle rect2 = new Rectangle(5, 4);Rectangle rect3 = new Rectangle(10, 4);// Print all three rectangles// Print one true statement comparing rectangles// Print one false statment comparing rectangles}} =========================================== public class Rectangle{ private int width;private int height;public Rectangle(int width, int height) {}}Using the Card.java class file, write a program to simulate a Deck of Cards. See Programming Project 8.7 (PP 8.7) from page 403 of your textbook (or view the attached image) for a description of what your program needs to do. Note that although the book description of the problem states that you should write the Card class, I do not want you to do that. You must use the Card file exactly as it is provided (NO modifications) and only write the DeckOfCards and Driver classes. public class Card{public final static int ACE = 1;public final static int TWO = 2;public final static int THREE = 3;public final static int FOUR = 4;public final static int FIVE = 5;public final static int SIX = 6;public final static int SEVEN = 7;public final static int EIGHT = 8;public final static int NINE = 9;public final static int TEN = 10;public final static int JACK = 11;public final static int QUEEN = 12;public final static int KING = 13; public final static int CLUBS = 1;public final static int DIAMONDS =…Implement the design of the Passenger class so that the following output is produced: The assumption is Bus base-fare is 450 taka. A passenger can carry upto 20 kg for free. 50 taka will be added if bag weight is between 21 and 50 kg. 100 taka will be added if bag weight is greater than 50 kg. [You are not allowed to change the code below] # Write your code here print(“Total Passenger:”, Passenger.count) p1 = Passenger(“Jack”) p1.set_bag_weight(90) p2 = Passenger(“Carol”) p2.set_bag_weight(10) p3 = Passenger(“Mike”) p3.set_bag_weight(25) print("=========================") p1.printDetail() print("=========================") p2.printDetail() print("=========================") p3.printDetail() print("=========================") print(“Total Passenger:”, Passenger.count) Output: Total Passenger: 0 ========================= Name: Jack Bus Fare: 550 taka ========================= Name: Carol Bus Fare: 450 taka ========================= Name: Mike Bus Fare: 500 taka =========================…
- Implement the below pseudo-code in a Java program using a while loop and aswitch-case statement. The program should be well structured, and the taskperformed under each option (at least options 'b' to 'e') should be implementedas a separate method.NOTE: The Scanner class does not have a method to input a character. Inorder to read a character from the keyboard, use one of the following methods(after declaring the Scanner object):static Scanner kb = new Scanner(System.in);1. char ch = kb.nextLine().charAt(0); OR2. char ch = kb.nextLine().toLowerCase().charAt(0);where kb is a Scanner class object.The second method above also converts the input to lowercase, which is oftenuseful. Though these methods allow the user to input more than one characteron the input line, the rest of the line (after capturing the first character withcharAt(0)) is discarded.If you also want to ignore the leading spaces before the first character thenuse:1. char ch = kb.nextLine().trim().charAt(0); OR2. char ch =…I need help adding a new line at the end of the output string here is my Java code, and it is all correct except at the end of the output it is requiring a newline after. import java.util.Scanner; public class LabProgram { //method drivingCost definition public static double drivingCost(double drivenMiles,double milesPerGallon,double dollarsPerGallon){ double yourValue; yourValue = (drivenMiles/milesPerGallon)*dollarsPerGallon; System.out.printf("%.2f ", yourValue); return yourValue;} public static void main(String[] args) { double milesPerGallon; double dollarsPerGallon; Scanner sc = new Scanner(System.in); milesPerGallon = sc.nextDouble(); dollarsPerGallon = sc.nextDouble(); drivingCost(10, milesPerGallon, dollarsPerGallon); drivingCost(50, milesPerGallon, dollarsPerGallon); drivingCost(400, milesPerGallon, dollarsPerGallon); }}I have this problem and I keep getting a error. "ShoppingCartPrinter.java:29: error: reached end of file while parsing } ^ 1 error. " Idk what to do. This is my code. public class ItemToPurchase {public class ItemToPurchase{private String itemName;private int itemPrice;private int itemQuantity; public ItemToPurchase(){this.itemName = "none";this.itemPrice = 0;this.itemQuantity = 0;} public ItemToPurchase(String itemName, int itemPrice, int itemQuantity){this.itemName = itemName;this.itemPrice = itemPrice;this.itemQuantity = itemQuantity;} public void setName(String itemName){this.itemName = itemName;} public String getName(){return itemName;} public void setPrice(int itemPrice){this.itemPrice = itemPrice;} public int getPrice(){return itemPrice;} public void setQuantity(int itemQuantity){this.itemQuantity = itemQuantity;} public int getQuantity(){return itemQuantity;} } class ShoppingCartPrinter{public static void main(String[] args){Scanner scnr = new Scanner(System.in);String…
- Implement the design of the Bird class so that the following output is produced: # Write your codes here.print(“No.of Bird=”, Bird.count)ostrich = Bird('Ostrich')duck = Bird("Duck", True)owl = Bird('Owl', True)print(“###########################”)ostrich.fly()duck.fly()owl.fly()duck.setType('Water Birds')owl.setType('Birds of Prey')print(“=========================”)ostrich.printDetail()print(“=========================”)duck.printDetail()print(“=========================”)owl.printDetail()print(“=========================”)print(“No.of Bird=”, Bird.count) Output:No.of Bird= 0###########################Ostrich can not flyDuck can flyOwl can fly===========================Name: OstrichType: Flightless Birds=========================== Name: DuckType: Water Birds===========================Name: OwlType: Birds of Prey===========================No.of Bird= 3Add a new Java class to your project by right clicking on the src folder in the Project pane and select New > Java Class.Enter Hours as the name for this class, and IntelliJ will add it to the files in the src folder for your project. Remember tocopy and insert the standard heading for the main method as you did for Program 2.Write a program that prompts the user to enter a number of hours, and produces the equivalent number of days as a wholenumber along with the number of hours left over. Assume that a day has exactly 24 hours. The following example showsthe format to use for your output, where the input entered by the user is underlined.Enter the number of hours: 100100 hours is 4 days, plus 4 hours.Define Variables: The number of hours will be a whole number, and we would like to obtain results as whole numbers ofdays and hours, so use the int data type to declare the variables to hold the numbers of hours input, as well as the results(the number of days and number of hours left…I have already written the program and have it right, but I need help write print statement for the testorder class so that the display result looks as shown in the images. I am having trouble getting that right. I will paste the program below so you can run it and attatch the image of display result. Program for Order Class: package homework; import java.util.Date; public class Order { //Declare final variables public static final int ON_ORDER = 0; public static final int CANCELLED = 1; public static final int SHIPPED = 2; //Declare local variables private int totalOrder; private String orderName; private Date date; private int status; private String shippingAddress; private String phoneNumber; private String billingAddress; //Constructor public Order(String name) { this.totalOrder += 1; this.orderName = name; this.status = ON_ORDER; this.date = new Date();} //Cancel the placed order…