in java
thanks for the question. The second part of the question where we need to create a class Vehicle is missing the class definition, hence it cannot be coded.
The first part is fully implemented. Below is the code with screenshot.
------------------------------------------------------------------------------------------------------------------------------------------------------
import java.util.Random; # for generating random number import java.util.Scanner; # for reading user input public class Demo { private static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { System.out.println("Welcome to my class - Demo"); while (true) { // infinte loop until user presses 4 System.out.println("[1] Square a number"); System.out.println("[2] Generate a random number"); System.out.println("[3] Months"); System.out.println("[4] Quit"); System.out.print("Enter a choice "); int choice = scanner.nextInt(); if (choice == 1) { squareIt(); // call this static method } else if (choice == 2) { generateRandomNumber();// call this static method } else if (choice == 3) { printMonths();// call this static method } else if (choice == 4) { System.out.println("Thank you for using my program."); break;// break out of the while loop } } } private static void squareIt() { // square number to 2 decimals double square = 0.0; System.out.print("Enter a number: "); square = scanner.nextDouble(); System.out.printf("The square of the number is %.2f", square * square); System.out.println(); } private static void generateRandomNumber() { / /generate 8 diigit number Random random = new Random(); System.out.println("Here is the 8 digit number: " + (10000000 + random.nextInt(100000000))); } private static void printMonths() { // prints the month name String[] monthNames = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; System.out.print("Enter a month number [1-12]: "); int month = scanner.nextInt(); if (1 <= month && month <= 12) { System.out.println("The month name is: " + monthNames[month - 1]); } else { System.out.println("Month number cannot be less than 1 or greater than 12."); } } }
=========================================================================================
thanks !
in java Create a new project named, firstInitialLastNameCS185EOS. Create and use a class that prints a title. Create a use a menu that contains the following items, and calls corresponding methods...
JAVA HELP (ARRAYS) Assignment Create a class named Module4 containing the following data members and methods (note that all data members and methods are for objects unless specified as being for the entire class) 1) Data members: none 2) Methods a. A method named displayContents that accepts an array of type int and prints their values to the b. A method named cemoveNegatives that accepts an array of type int, copies all its non-negative the new array should be the...
Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type(does not mention the data type of the variable coffeeType), price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public...
JAVA :The following are descriptions of classes that you will create. Think of these as service providers. They provide a service to who ever want to use them. You will also write a TestClass with a main() method that fully exercises the classes that you create. To exercise a class, make some instances of the class, and call the methods of the class using these objects. Paste in the output from the test program that demonstrates your classes’ functionality. Testing...
Project overview: Create a java graphics program that displays an order menu and bill from a Sandwich shop, or any other establishment you prefer. In this program the design is left up to the programmer however good object oriented design is required. Below are two images that should be used to assist in development of your program. Items are selected on the Order Calculator and the Message window that displays the Subtotal, Tax and Total is displayed when the Calculate...
// Client application class and service class Create a NetBeans project named StudentClient following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. Add a class named Student to the StudentClient project following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. After you have created your NetBeans Project your application class StudentC lient should contain the following executable code: package studentclient; public class...
create java application with the following specifications: -create an employee class with the following attibutes: name and salary -add constuctor with arguments to initialize the attributes to valid values -write corresponding get and set methods for the attributes -add a method in Employee called verify() that returns true/false and validates that the salary falls in range1,000.00-99,999.99 Add a test application class to allow the user to enter employee information and display output: -using input(either scanner or jOption), allow user to...
JAVA Problem: Coffee do not use ArrayList or Case Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public void prepare ();...
Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one menu item called Search. Clicking on search should prompt the user using a JOptionPane input dialog to enter a car make. The GUI should then display only cars of that make. You will need to write a second menu...
1. Create a new multi-class Java program which implements a vending machine simulator which contains the following functionality: A) At program startup, the vending machine is loaded with a variety of products in a variety of packaging for example soda/tonic/Coke in bottles, peanuts in bags, juice in cartons, etc. Also included is the cost of each item. The program should be designed to easily load a different set of products easily (for example, from a file). Also at program startup,...
Create a C# Console program. Add a class named Employee that has the following public fields: • Name. The name field references a String object that holds the employee’s name. • IDNumber. The IDNumber is an int that holds the employee’s ID number. • Department. The department field is a String that holds the name of the department where the employee works. • Position. The position field is a String that holds the employee’s job title. Once you have written...