Question

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...

in java

  1. Create a new project named, firstInitialLastNameCS185EOS.
  2. Create and use a class that prints a title.  
  3. Create a use a menu that contains the following items, and calls corresponding methods that do the tasks the menu describes. Use classes when they're appropriate. Keep the driver class as simple as possible. Give each class, method and property simple, descriptive names using Hungarian notation.
    1. Square a number
      1. Simply pass a decimal-type number to the object that does this task. Process its square and format the number so it has no more than 2 decimal places.
    2. Generate a random number
      1. Generate an 8 digit integer that could be used as a temporary password.  
    3. Months
      1. Enter a number from the keyboard, and return its corresponding month as a string to the console using arrays of months.
    4. Process objects
      1. Make an array of objects of the Vehicle class. Each time an object of the Vehicle class is created, keep track of the number of objects and print that number out when the summary is printed.
      2. Use polymorphism to store each vehicle in its own category; for example, create classes of Truck, Sedan, Roadster, Hatchback, and SUV that all inherit from the Vehicle class.
        1. In the Vehicle class, store the make, model and year
        2. In each of the other four classes, store a color. In the Truck class, store the fuel type, Gas or Diesel. In the Roadster class, store the engine type such as 4, 6, 8 or 12 cylinder. In the Sedan class, store the number of doors, 2 or 4.
        3. Print out a report to both the console and to a text file so it can be printed.
    5. Recursion
      1. Demonstrate recursion
  4. When each menu item is selected using an integer 1 through 5, cause the execution of each corresponding object.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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.");
        }
    }
}

=========================================================================================

import java.util.Random; Run: Demo C:\Program FileslJavaljdk-11binljava.exe -javaagent:C:\Program Fi Welcome to my class D

thanks !

Add a comment
Know the answer?
Add Answer to:
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...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA HELP (ARRAYS) Assignment Create a class named Module4 containing the following data members and 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...

    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...

    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...

    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...

    // 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...

    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....

    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 me...

    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...

    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:...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT