Problem 01: GradeConverter
Problem 02: Course
Whether you face any problem or need any modification
then share with me in the comment section, I'll happy to help
you.
Code
//GradeConverter class
public class GradeConverter
{
//static method to convert from letterGrade to
NumericGrade
public static double letterGradeToNumericGrade(String
letterGrade)
{
switch(letterGrade)
{
case "A+": case
"A": return 4.0;
case "A-":
return 3.7;
case "B+":
return 3.3;
case "B": return
3.0;
case "B-":
return 2.7;
case "C+":
return 2.3;
case "C": return
2.0;
case "C-":
return 1.7;
case "D+":
return 1.3;
case "D": return
1.0;
}
return 0.0;
}
//static method to conver from numericGrade to
LetterGrade
public static String numericGradeToLetterGrade(double
numericGrade)
{
if(numericGrade == 4.0) return
"A+";
if(numericGrade == 3.7) return
"A-";
if(numericGrade == 3.3) return
"B+";
if(numericGrade == 3.0) return
"B";
if(numericGrade == 2.7) return
"B-";
if(numericGrade == 2.3) return
"C+";
if(numericGrade == 2.0) return
"C";
if(numericGrade == 1.7) return
"C-";
if(numericGrade == 1.3) return
"D+";
if(numericGrade == 1.0) return
"D";
return "F";
}
}
//Course class
class Course
{
//attributes
private String courseName;
private double credits;
private String letterGrade;
private double numericGrade;
//constructor
public Course(String courseName, double credits,
String letterGrade)
{
this.courseName = courseName;
this.credits = credits;
this.letterGrade =
letterGrade;
numericGrade =
GradeConverter.letterGradeToNumericGrade(letterGrade);
}
//another constructor
public Course(String courseName, double credits,
double numericGrade)
{
this.courseName = courseName;
this.credits = credits;
this.numericGrade =
numericGrade;
letterGrade =
GradeConverter.numericGradeToLetterGrade(numericGrade);
}
//getter methods
public String getCcourseName() { return
courseName;}
public double getCredits(){ return credits; }
public String getLetterGrade(){ return
letterGrade;}
public double getNumericGrade(){ return
numericGrade;}
//setter methods
public void setCcourseName(String courseName) {
this.courseName = courseName;}
public void setCredits(double credits){ this.credits =
credits; }
public void setLetterGrade(String letterGrade){
this.letterGrade = letterGrade;}
public void setNumericGrade(double numericGrade){
this.numericGrade = numericGrade;}
}
Problem 01: GradeConverter design a GradeConverter class. This class does not have any attributes. a static...
Create a java class for an object called Student which contains the following private attributes: a given name (String), a surname (family name) (String), a student ID number (an 8 digit number, String or int) which does not begin with 0. There should be a constructor that accepts two name parameters (given and family names) and an overloaded constructor accepting two name parameters and a student number. The constructor taking two parameters should assign a random number of 8 digits....
using CSCI300 java Given the following UML Class Diagram Club_Card # card_num : String # name : String # age: int # year: int + Club_Card (all parameters) + Setters & Getters + toString() : String + equals(x: Object): boolean [10 pts] Define the class Club_Card, which contains: 1. All arguments constructor which accepts all required arguments from the main and instantiate a Club_Card object. 2. Set & get method for each data attribute. 3. A toString() method which returns...
C++ computer science Given the partial class HardDrive implementation below, implement all of the following: 1: default constructor that initialized the attributes with proper default data of your choice. 2: destructor() method, that releases all the dynamically allocated memory. 3: copy constructor() method: That properly manages the dynamic array when the object is passed by value to a function as a parameter. 4: overload the assignment operator: To properly handle copying the dynamic array when one object is assigned to...
Problem 2 (36 pts): You are going to design a class named Computer. The class contains: A string field named manufacturer. A string field named serialNumber. A double field named speed (measured in Gigahertz). A constructor that has a parameter for each data field and sets the data fields with these values. A no-arg constructor that sets string fieldsto and numeric fields to 0. Mutator and Accessor methods for each data field. A method toString) that returns each field value...
In java netbean8.1 or 8.2 please. The class name is Stock. It has 5 private attributes (name, symbol, numberOfShares, currentPrice and boughtPrice)and one static private attribute (numberOfStocks). All attributes must be initialized (name and symbol to “No name/ symbol yet” and numberOfShares, currentPrice and boughtPrice to 0. Create two constructors, one with no arguments and the other with all the attributes. (However, remember to increase the numberOfStocks in both constructors. Write the necessary mutators and accessors (getters and setters) for...
Create an abstract class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create an abstract method called earnings. Create another class HourlyEmployee that inherits from the abstract Employee class. HourEmployee must use the inherited parent class variables and add in attributes HourlyRate and HoursWorked. Your HourEmployee class should...
Create an abstract class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create an abstract method called earnings. Create another class HourlyEmployee that inherits from the abstract Employee class. HourEmployee must use the inherited parent class variables and add in attributes HourlyRate and HoursWorked. Your HourEmployee class should...
An abstract class doesn't have a constructor (because you cannot make an object of the abstract class). It should have at least one method, which then has to be overridden in all derived classes. Here is an example: abstract void run(); class Honda4 extends Bike{ public static void main(String args[]){ obj.run(); } You are to create an abstract class called Shape, which has an abstract method called computeArea(). Derive a Circle class from Shape. (Circle is similar to your previous...
The class Engineer Test below is used to test two other class named Project & Engineer. A project has three attributes: projNo (int), projName (string), revenue (double). Add a parameterized constructor, and setters & getters for all attributes. An engineer has four attributes: jobld (int), name (string), rate (double), and a list of projects. For each project, the engineer has a specific amount as profit (project revenue rate). Add a constructor that initializes the attributes: jobild, name and rate. Implement...