Related questions
I need help with creating a Java program described in the image below:
CourseInformation.java:
import java.util.Scanner;
public class CourseInformation {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
Course myCourse = new Course();
OfferedCourse myOfferedCourse = new OfferedCourse();
String courseNumber, courseTitle;
String oCourseNumber, oCourseTitle, instructorName, location, classTime;
courseNumber = scnr.nextLine();
courseTitle = scnr.nextLine();
oCourseNumber = scnr.nextLine();
oCourseTitle = scnr.nextLine();
instructorName = scnr.nextLine();
location = scnr.nextLine();
classTime = scnr.nextLine();
myCourse.setCourseNumber(courseNumber);
myCourse.setCourseTitle(courseTitle);
myCourse.printInfo();
myOfferedCourse.setCourseNumber(oCourseNumber);
myOfferedCourse.setCourseTitle(oCourseTitle);
myOfferedCourse.setInstructorName(instructorName);
myOfferedCourse.setLocation(location);
myOfferedCourse.setClassTime(classTime);
myOfferedCourse.printInfo();
System.out.println(" Instructor Name: " + myOfferedCourse.getInstructorName());
System.out.println(" Location: " + myOfferedCourse.getLocation());
System.out.println(" Class Time: " + myOfferedCourse.getClassTime());
}
}
Course.java:
public class Course{
// TODO: Declare private fields
// TODO: Define mutator methods -
// setCourseNumber(), setCourseTitle()
// TODO: Define accessor methods -
// getCourseNumber(), getCourseTitle()
// TODO: Define printInfo()
}
OfferedCourse.java:
public class OfferedCourse extends Course {
// TODO: Declare private fields
// TODO: Define mutator methods -
// setInstructorName(), setLocation(), setClassTime()
// TODO: Define accessor methods -
// getInstructorName(), getLocation(), getClassTime()
}
Trending nowThis is a popular solution!
Step by stepSolved in 6 steps with 5 images
- Provide the UML class diagram for the program below. import java.util.ArrayList; import java.util.Scanner; //Define the class Fraction class Fraction { private int n, d; public Fraction() { this.n = this.d = 0; //Initialize the values } public Fraction(int n, int d) { this.n = n; //Initialize the variables this.d = d; } //Define the getter function getNum() that returns the numerator public int getNum() { //Returns numerator return n; } //Define the getter function getDen() that returns the denominator public int getDen() { //Returns denominator return d; } //Define the boolean function isZero() that returns 0 if numerator is 0 and denominator is not equals to zero public boolean isZero() { return(getNum() == 0 && getDen() != 0); } //Define the function getSimplifiedFraction() that returns the simplified fraction public String getSimplifiedFraction() { //Decalre the string variable result to store the result String result = ""; //if the numerator and...arrow_forwardimport java.util.Scanner; public class TicketCounter { public static void main (String [] args) { int awardPoints; int userTickets; Scanner scnr = new Scanner(System.in); userTickets = scnr.nextInt(); // Program will be tested with values: 5, 6, 7, 8. if (userTickets < 6) { awardPoints = 1; { else { awardPoints = userTickets; } System.out.println(awardPoints); }}arrow_forward1 import java.util.Scanner; 2 3 public class Relational { public static void main(String (] args) { int userStreak = 0; int userPoints = 0; 4 5 7 Scanner input = new Scanner(System.in); userStreak = input.nextInt(); // Program will be 8 9. 10 if (//Your code goes here) { userPoints = 10; } else { userPoints = 0; 11 12 13 14 15 16 } 17 System.out.println(userPoints); } 18 19 20 }arrow_forward
- please help me with this error problem in java: import java.util.Arrays; import java.util.Scanner; import Project1.Employee; public class Payroll { privateStringfirstName; privateStringlastName; privateintemployeeNumber; privateEmployee[]employees; privateintemployeeCount; // Constructors publicStringgetLastName(){ returnlastName; } publicPayroll(){ employees=newEmployee[100]; employeeCount=0; } publicstaticvoidmain(String[]args){ Payrollpayroll=newPayroll(); payroll.run(); } publicvoidrun(){ Scannerkeyboard=newScanner(System.in); while(true){ System.out.println("Welcome to the Payroll System." +"Choose one of the following opions from 1-5:\n"); System.out.print("1) Create an employee\n" +"2)Search for an employee by last name\n" +"3)Display an employee by employee number\n" +"4)Run payroll\n" +"5)Quit\n"); intChoice=keyboard.nextInt(); keyboard.nextLine(); if(Choice==1){ createEmployee(); }elseif(Choice==2){ searchEmployee(); }elseif(Choice==3){...arrow_forwardimport java.util.Scanner;public class Main{ public static final double OVERTIME_RATE = 1.5; public static final double HOLD = .1; public static final double TAX = .2; public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Name: "); String name = sc.nextLine(); System.out.print("SSN: "); String ssn = sc.nextLine(); int regularHours; System.out.print("Regular Hours: "); regularHours = sc.nextInt(); int overtimeHours; System.out.print("Overtime Hours: "); overtimeHours = sc.nextInt(); double hourlypayRate; System.out.print("Hourly pay rate: $"); hourlypayRate = sc.nextDouble(); double regularPay = regularHours * hourlypayRate; double overtimeRate = hourlypayRate * OVERTIME_RATE; double overtimePay = overtimeHours * OVERTIME_RATE * hourlypayRate; double gross = regularPay + overtimePay; double wh = gross...arrow_forwardHow do I mahe my code output results Java? Code: import java.util.Scanner; class FinalExamAnswer{ public static void main(String [] args) { manipulateString(); //calls function } //your code here public static void manipulateString() { Scanner sc=new Scanner(System.in); //create Scanner instance System.out.print("Enter a sentence: "); String sentence=sc.nextLine(); //input a sentence String[] words=sentence.split(" "); //split the sentence at space and store it in array for(int i=0;i<words.length;i++) //i from 0 to last index { if(i%2==0) //if even index words[i]=words[i].toUpperCase(); //converted to upper case else //if odd index words[i]=words[i].toLowerCase(); //converted to lower case } for(int i=words.length-1;i>=0;i--) //i from last index to 0 { System.out.print(words[i]+"...arrow_forward
- Answer with a given JAVA question below. Consider the following code: public class Quiz{ public String name; public double totalPoints; public String getName() { return this.name; } public double getTotalPoints() { return this.totalPoints; } } Based on the Java code, explain where information hiding is being violated, why it is considered a violation, and how a programmer should fix the violation.arrow_forwardimport java.util.Scanner;public class LabProgram { public static void main(String args[]) { Scanner scnr = new Scanner(System.in); int credits; int seed; GVDie die1, die2; die1 = new GVDie(); die2 = new GVDie(); // Read random seed to support testing (do not alter) seed = scnr.nextInt(); die1.setSeed(seed); // Read starting credits credits = scnr.nextInt(); int rounds = 0; while (credits > 0) { // Step 1: Roll both dice die1.roll(); die2.roll(); int total = die1.getValue() + die2.getValue(); if (total == 7 || total == 11) { // Player wins one credit credits++; // UPDATE - print the dice total here System.out.println("Dice total: " + total); //UPDATE - break the loop and end the round break; } else if (total == 2 ||...arrow_forwardimport java.util.Scanner; public class ShadyRestRoom2{ public static void main(String[] args) { int selection; int price; String result; final int QUEEN = 1, KING = 2, SUITE = 3; final int QPRICE = 125, KPRICE = 139,SPRICE = 165; final String QSTRING = "Queen bed", KSTRING = "King bed", SSTRING = "Suite with a king bed and pull-out couch", INVALIDSTRING = "an invalid option"; Scanner in = new Scanner(System.in); System.out.println("\t\n\nMenu\n"); System.out.println("(" + QUEEN + ") " + QSTRING); System.out.println("(" + KING + ") " + KSTRING); System.out.println("(" + SUITE + ") " + SSTRING); System.out.print("Enter Selection (1, 2, or 3) >> "); selection = in.nextInt(); if(selection == QUEEN){ result = QSTRING; price = QPRICE; } else if(selection == KING){ result = KSTRING; price = KPRICE; } else if (selection == SUITE){ result = SSTRING; price =...arrow_forward
- Java. Tally counter that increases and decreases. Refer to screenshot. Here is some code (class PoD): import java.util.*; public class PoD { public static void main (String [] args ) {Scanner in = new Scanner( System.in );PrettyTally tally = new PrettyTally(in.next());while (in.hasNext()){String nextTask = in.next();if (nextTask.equals("increment")){tally.increment();} else if (nextTask.equals("toString")){System.out.println(tally);}else if (nextTask.equals("decrement")){tally.decrement();}}in.close();}} Class PrettyTally: public class PrettyTally extends TallyCounter{ } Class TallyCounter import java.util.*; public class TallyCounter { protected int count=0;public TallyCounter(){this.count = 0;} public void increment(){this.count++;}public int get(){return this.count;}}arrow_forwardCmplt all the terminal in code. Output requirements.arrow_forwardIn java Using the following code: import java.util.*; public class Test { public static void main(String[] args) { /* PART 1 - Object and Classes */ System.out.println("Part 1: Object and Classes\n"); // Create scanner object Scanner input = new Scanner(System.in); // Prompt user to enter new airport name System.out.println("Enter airport name: "); // Create airport object (with its name ap) using inputted name Airport ap = new Airport(input.nextLine()); // Prompt user to enter first gate's name System.out.println("Enter first gate's name: "); // Store inputted name as a String variable called n1 String n1 = input.nextLine(); // TODO: Prompt user to enter first gate's length in meters // TODO: Store inputted length as an int variable called l1 // TODO: Create first gate object (with its name g1) using n1 and l1 // TODO: Prompt user to enter second gate's name // Store inputted name as a String variable called n2 String n2 = input.next(); // TODO: Prompt user to enter second gate's...arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education