Question

Create a Business class: Instance variables: Student id 1000 - 9999 Student name Present Student email...

Create a Business class: Instance variables: Student id 1000 - 9999 Student name Present Student email address Present Number of hours 3.5 - 18 Two constructors should be coded, one that accepts no arguments and sets every field to its default value, and one that accepts all four fields, and assigns the passed values into the instance variables. For each instance variable create two methods; a getter and a setter. Add a static method to the class that will accept the number of hours as an argument. In this static method, multiply the number of hours by 60.50 and return the result.

Create a Presentation class: The presentation class will ask the user to input information into the four fields listed above and validate those fields. That information will be passed over to the business class using the constructor. This class with be divided into methods and tested for valid data. Your presentation class will display all the values from the four fields listed above returned from the business class; along with the amount calculated from the static method.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer: Hello! Dear student, kindly find your solution here. This program is working well and error, giving the desired output. If you have any queries, feel free to ask me. Thanks.

import java.io.*;           //import packages
import java.lang.*;
import java.util.Scanner;

class Business            //create class
{
int Student_id;               //declare variables
String Student_name,email_id;
public static double Student_hours,result;       //static type variable for static method

Business()               //defalut constructor to assign defalut values
{
   Student_id = 0;
   Student_name =   "XX";
   email_id = "xxx";
   Student_hours = 0.0;
}
Business(String name,int id,String email) //parametierized contructor
{
   Student_name = name;
   Student_id = id;
   email_id = email;
}
public static void Hours(double hours)       //static method
{
Student_hours = hours;
result = Student_hours*60.50;
}
public void get()                           //getter method
{
System.out.println("Student name: "+Student_name);
System.out.println("Student ID: "+Student_id);
System.out.println("Student Email-Id: "+email_id);
System.out.println("Student Hours: "+Student_hours);
System.out.println("Result: "+result);
}
}
class Presentation //create presentation class
{
public static void main(String[]args)
{
   String na,mail;               //variable declaration
   double hrs;
   int id;
   Scanner in = new Scanner(System.in);       //call scanner for input
   System.out.   println("Enter Student Name: ");       //takes input for all fields
   na = in.nextLine();
   System.out.   println("Enter Student e-mail: ");
   mail = in.nextLine();
   System.out.   println("Enter Student ID: ");
   id = in.nextInt();
   if(id>=1000 && id<9999) //validate field
   {
   System.out.println("");
   }
   else
   {
   System.out.println("This is invalid Student ID!!"); //invalid data message
   System.out.println("Try again!");
   System.exit(0);
   }
  
   System.out.   println("Enter Student Hours: ");
   hrs = in.nextDouble();
   if(hrs>3.5 && hrs<18)               //data validate
   {
   System.out.println("");
   }
   else
   {
   System.out.println("This is invalid Student hours!!"); //invalid data message
   System.out.println("Try again!");
   System.exit(0);
   }

   Business b1 = new Business(); //call defalut constructor
   Business b2 = new Business(na,id,mail);   //call parametierized constructor
   b2.Hours(hrs);                                       //call methods
   b2.get();
}
}


  

Add a comment
Know the answer?
Add Answer to:
Create a Business class: Instance variables: Student id 1000 - 9999 Student name Present Student email...
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
  • You are to create a class Appointment.java that will have the following: 5 Instance variables: private...

    You are to create a class Appointment.java that will have the following: 5 Instance variables: private String month private int day private int year private int hour private int minute 1 default constructor public Appointment() 1 non-default constructor that accepts arguments for all instance variables, your constructor must call the setter methods below to set the values of the instance variables public Appointment(String monthPassed, int dayPassed, int yearPassed, int hourPassed, int minutePassed) 5 setter methods (one for each instance variable)...

  • Student class: Instance variables name id Constructors: Default constructor Constructor that has id and name passed...

    Student class: Instance variables name id Constructors: Default constructor Constructor that has id and name passed to the constructor Methods: Accessors int getID( ) String getName( ) Class Roster: This class will implement the functionality of all roster for school. Instance Variables a final int MAX_NUM representing the maximum number of students allowed on the roster an ArrayList storing students Constructors a default constructor should initialize the list to empty strings a single parameter constructor that takes an ArrayList<Student> Both...

  • a) Create an abstract class Student. The class contains fields for student Id number, name, and...

    a) Create an abstract class Student. The class contains fields for student Id number, name, and tuition. Includes a constructor that requires parameters for the ID number and name. Include get and set method for each field; setTuition() method is abstract. b) The Student class should throw an exception named InvalidNameException when it receives an invalid student name (student name is invalid if it contains digits). c) Create three student subclasses named UndergradStudent, GradeStudent, and StudentAtLarge, each with a unique...

  • Write a class called Student. The specification for a Student is: Three Instance fields name -...

    Write a class called Student. The specification for a Student is: Three Instance fields name - a String of the student's full name totalQuizScore - double numQuizesTaken - int Constructor Default construtor that sets the instance fields to a default value Parameterized constructor that sets the name instance field to a parameter value and set the other instance fields to a default value. Methods setName - sets or changes the student name by taking in a parameter getName - returns...

  • Design and implement a class called Flight that represents an airline flight. It should contain instance data that represents the airline name

    Design and implement a class called Flight that represents an airline flight. It should contain instance data that represents the airline name, flight number, and the flight’s origin and destination cities. Define the Flight constructor to accept and initialize all instance data. Include getter and setter methods for all instance data. Include a toString method that returns a one-line description of the flight. Create a driver class called FlightTest, whose main method instantiates and updates several Flight objects.

  • PYTHON*************** Create a Person Class that: Accepts First Name, Last Name, Age, and Gender Has a...

    PYTHON*************** Create a Person Class that: Accepts First Name, Last Name, Age, and Gender Has a method that adds all persons Validate all input, not left empty for First Name, Last Name, Gender and numeric for age and throw an exception if it does not validate within the class. Create a Student Class that: Inherits the Person Class Accepts GPA Validate GPA (>= 0 and <= 4.0) and throw exception if it does not validate within the class. Has methods...

  • In java code: Write a Temperature class that has two private instance variables: • degrees: a...

    In java code: Write a Temperature class that has two private instance variables: • degrees: a double that holds the temperature value • scale: a character either ‘C’ for Celsius or ‘F’ for Fahrenheit (either in uppercase or lowercase) The class should have (1) four constructor methods: one for each instance variable (assume zero degrees if no value is specified and assume Celsius if no scale is specified), one with two parameters for the two instance variables, and a no-argument...

  • Create a class called Student. This class will hold the first name, last name, and test...

    Create a class called Student. This class will hold the first name, last name, and test grades for a student. Use separate files to create the class (.h and .cpp) Private Variables Two strings for the first and last name A float pointer to hold the starting address for an array of grades An integer for the number of grades Constructor This is to be a default constructor It takes as input the first and last name, and the number...

  • Graded Exercise Create a class named Student. A Student has fields for an ID number, number...

    Graded Exercise Create a class named Student. A Student has fields for an ID number, number of credit hours earned, and number of points earned. (For example, many schools compute grade point averages based on a scale of 4, so a three-credit-hour class in which a student earns an A is worth 12 points.) Include methods to assign values to all fields. A Student also has a field for grade point average. Include a method to compute the grade point...

  • Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number...

    Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number of quarters, number of dimes, number of nickels, and number of pennies. Include two constructors (non-argument constructor that assigns 1 to each coin, and another constructor that takes necessary arguments to create an object), needed getter and setter methods, method toString (to print coins objects in a meaningful way), and method equals (to compare two coins objects based on number of coins). Also include...

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