Question

In: Computer Science

Write a menu driven program in Java (OOP) That contain class for Botique. Data members include...

Write a menu driven program in Java (OOP)
That contain class for Botique.
Data members include code ,colour , size ,Quantity
Your class should contains app accessors and mutators method
Your class should contain Parametric and non-parametric constructors (use constructor chaining)
Your class should have input and display method.


Solutions

Expert Solution

Botique.java

import java.util.Scanner;

public class Botique {
        private String code;
        private String colour;
        private double size;
        private int quantity;

        public Botique(String code, String colour, double size, int quantity) {
                this.code = code;
                this.colour = colour;
                this.size = size;
                this.quantity = quantity;
        }

        public Botique() {
                this.code = "";
                this.colour = "";
                this.size = 0.0;
                this.quantity = 0;
        }

        public String getCode() {
                return code;
        }

        public void setCode(String code) {
                this.code = code;
        }

        public String getColour() {
                return colour;
        }

        public void setColour(String colour) {
                this.colour = colour;
        }

        public double getSize() {
                return size;
        }

        public void setSize(double size) {
                this.size = size;
        }

        public int getQuantity() {
                return quantity;
        }

        public void setQuantity(int quantity) {
                this.quantity = quantity;
        }

        public void input(Scanner sc) {
                System.out.println("Please enter code of Botique: ");
                this.code = sc.nextLine();
                System.out.println("Please enter colour of Botique: ");
                this.colour = sc.nextLine();
                System.out.println("Please enter size of Botique: ");
                this.size = Double.parseDouble(sc.nextLine());
                System.out.println("Please enter quantity of Botique: ");
                this.quantity = Integer.parseInt(sc.nextLine());
        }

        public void display() {
                System.out.println("Botique code: " + this.code);
                System.out.println("Botique colour: " + this.colour);
                System.out.println("Botique size: " + this.size);
                System.out.println("Botique quantity: " + this.quantity);
        }

}

BotiqueTest.java

import java.util.Scanner;

public class BotiqueTest {
        public static void main(String[] args) {

                Scanner sc = new Scanner(System.in);
                int choice = 0;
                Botique b = new Botique();
                System.out.println("Welcome!. A default Botique is created for you.");
                while (choice != 7) {
                        System.out.println();
                        printMenu();
                        choice = Integer.parseInt(sc.nextLine());
                        if (choice == 1) {
                                b.input(sc);
                        } else if (choice == 2) {
                                System.out.println("Please enter code of Botique: ");
                                b.setCode(sc.nextLine());
                        } else if (choice == 3) {
                                System.out.println("Please enter colour of Botique: ");
                                b.setColour(sc.nextLine());
                        } else if (choice == 4) {
                                System.out.println("Please enter size of Botique: ");
                                b.setSize(Double.parseDouble(sc.nextLine()));
                        } else if (choice == 5) {
                                System.out.println("Please enter quantity of Botique: ");
                                b.setQuantity(Integer.parseInt(sc.nextLine()));
                        } else if (choice == 6) {
                                b.display();
                        } else if (choice == 7) {
                                System.out.println("Thanks!");
                        } else {
                                System.out.println("Please choose a correct option.");
                        }
                }
        }

        public static void printMenu() {
                System.out.println("Please choose from options below: ");
                System.out.println("1. Take initial values for Botique.");
                System.out.println("2. Edit code of Botique.");
                System.out.println("3. Edit colour of Botique.");
                System.out.println("4. Edit size of Botique.");
                System.out.println("5. Edit quantity of Botique.");
                System.out.println("6. Display Botique.");
                System.out.println("7. Exit.");
                System.out.println("Enter Choice (1 - 7): ");
        }
}

Output

Welcome!. A default Botique is created for you.

Please choose from options below:
1. Take initial values for Botique.
2. Edit code of Botique.
3. Edit colour of Botique.
4. Edit size of Botique.
5. Edit quantity of Botique.
6. Display Botique.
7. Exit.
Enter Choice (1 - 7):
6
Botique code:
Botique colour:
Botique size: 0.0
Botique quantity: 0

Please choose from options below:
1. Take initial values for Botique.
2. Edit code of Botique.
3. Edit colour of Botique.
4. Edit size of Botique.
5. Edit quantity of Botique.
6. Display Botique.
7. Exit.
Enter Choice (1 - 7):
2
Please enter code of Botique:
123

Please choose from options below:
1. Take initial values for Botique.
2. Edit code of Botique.
3. Edit colour of Botique.
4. Edit size of Botique.
5. Edit quantity of Botique.
6. Display Botique.
7. Exit.
Enter Choice (1 - 7):
6
Botique code: 123
Botique colour:
Botique size: 0.0
Botique quantity: 0

Please choose from options below:
1. Take initial values for Botique.
2. Edit code of Botique.
3. Edit colour of Botique.
4. Edit size of Botique.
5. Edit quantity of Botique.
6. Display Botique.
7. Exit.
Enter Choice (1 - 7):
3
Please enter colour of Botique:
Red

Please choose from options below:
1. Take initial values for Botique.
2. Edit code of Botique.
3. Edit colour of Botique.
4. Edit size of Botique.
5. Edit quantity of Botique.
6. Display Botique.
7. Exit.
Enter Choice (1 - 7):
6
Botique code: 123
Botique colour: Red
Botique size: 0.0
Botique quantity: 0

Please choose from options below:
1. Take initial values for Botique.
2. Edit code of Botique.
3. Edit colour of Botique.
4. Edit size of Botique.
5. Edit quantity of Botique.
6. Display Botique.
7. Exit.
Enter Choice (1 - 7):
1
Please enter code of Botique:
11
Please enter colour of Botique:
Green
Please enter size of Botique:
2.5
Please enter quantity of Botique:
3

Please choose from options below:
1. Take initial values for Botique.
2. Edit code of Botique.
3. Edit colour of Botique.
4. Edit size of Botique.
5. Edit quantity of Botique.
6. Display Botique.
7. Exit.
Enter Choice (1 - 7):
6
Botique code: 11
Botique colour: Green
Botique size: 2.5
Botique quantity: 3

Please choose from options below:
1. Take initial values for Botique.
2. Edit code of Botique.
3. Edit colour of Botique.
4. Edit size of Botique.
5. Edit quantity of Botique.
6. Display Botique.
7. Exit.
Enter Choice (1 - 7):
9
Please choose a correct option.

Please choose from options below:
1. Take initial values for Botique.
2. Edit code of Botique.
3. Edit colour of Botique.
4. Edit size of Botique.
5. Edit quantity of Botique.
6. Display Botique.
7. Exit.
Enter Choice (1 - 7):
6
Botique code: 11
Botique colour: Green
Botique size: 2.5
Botique quantity: 3

Please choose from options below:
1. Take initial values for Botique.
2. Edit code of Botique.
3. Edit colour of Botique.
4. Edit size of Botique.
5. Edit quantity of Botique.
6. Display Botique.
7. Exit.
Enter Choice (1 - 7):
7
Thanks!


Related Solutions

write a program in java that contain a class for botique . data member include code...
write a program in java that contain a class for botique . data member include code , color , size , quantity . your class should contains all accessor and mutator methods , non paraqmetric constructor , parametric constructor , input andvidsplay method
PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java...
PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java program that will solve the following problem. The program uses one and two-dimensional arrays to accomplish the tasks specified below. The menu is shown below. Please build a control panel as follows: (Note: the first letter is shown as bold for emphasis and you do not have to make them bold in your program.) Help SetParams FillArray DisplayResults Quit Upon program execution, the screen...
The Menu-driven Program: Write a menu-driven program to implement a roomsboard for a classroom reservations system....
The Menu-driven Program: Write a menu-driven program to implement a roomsboard for a classroom reservations system. The menu includes the following options: Add new room. The program will prompt the user to enter the roomID, courseID and time of the new reserved room, then will call the add() method from the RoomsBoard class. Remove all occurrences of a room. The program will prompt the user to input the room ID to be removed, then call the remove() method from the...
Java Write a menu driven program that implements the following linked list operations : INSERT (at...
Java Write a menu driven program that implements the following linked list operations : INSERT (at the beginning) INSERT_ALPHA (in alphabetical order) DELETE (Identify by contents, i.e. "John", not #3) COUNT CLEAR
Write a menu driven Java program which uses a method for each of the following operations:...
Write a menu driven Java program which uses a method for each of the following operations: (Note : The user should be allowed to repeat the operations as long as he wants to. Use appropriate number of parameters and return type for each method.) A. to find the sum of the following series (up to N terms). The program should    display the terms:              22 + 42 + 62… For example, if N=4, then the program should display the following...
This is an exercise for a menu-driven program. Program should use shell functions. Write a program...
This is an exercise for a menu-driven program. Program should use shell functions. Write a program that displays the following menu: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a rectangle 3. Calculate the area of a triangle 4. Quit Enter your choice (1-4) If the user enters 1, the program should ask for the radius of the circle and then display the area. Use the following formula to calculate the circle’s area: ?...
Write a menu-driven program to handle the flow of widgets into and out of a warehouse....
Write a menu-driven program to handle the flow of widgets into and out of a warehouse.     The warehouse will have numerous deliveries of new widgets and orders for widgets     The widgets in a filled order are billed at a profit of 50 percent over their cost     Each delivery of new widgets may have a different cost associated with it     The accountants for the firm have instituted a last-in, first-out system for filling orders         the newest...
Write a menu-driven program to test the three functions conver_tlength(), convert_width(), convert_volume() in a program. Program...
Write a menu-driven program to test the three functions conver_tlength(), convert_width(), convert_volume() in a program. Program should allow the user to select one of the options according to whether lengths, weights or volume are to be converted, read the volue to be converted and the units, and then call the appropriate function to carry out the conversion In unit out unit I C (inch to centimeter 1 in = 2.4 cm) F C (feet to centimeter 1 ft = 30.4...
Write a C++ program to run a menu driven program with the following choices: 1) Display...
Write a C++ program to run a menu driven program with the following choices: 1) Display the grades 2) Adjust grade 3) Display Average for each student 4) Display number of student with at least a B 5) Quit requirements: 1. Write a function called getValidGrade that allows a user to enter in an integer and loops until a valid number that is >= 0 and <= 100 is entered. It returns the valid value. 2. Write a function called...
Develop a java program with a class named friend with data members like name, phno and...
Develop a java program with a class named friend with data members like name, phno and hobby. Use Parameterized constructor to create two friend objects and invoke checkhobby method which takes only one parameter, to find whether they have same hobby or different hobbies
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT