a.
Explanation of Solution
Program:
File name: “CollegeCourse.java”
//Define a class named CollegeCourse
public class CollegeCourse
{
//Declare the private variables
private String courseID;
private int credits;
private char grade;
//Define a get method that returns the course ID
public String getID()
{
//Return the value
return courseID;
}
//Define a get method that returns the credit hours
public int getCredits()
{
//Return the value
return credits;
}
//Define a get method that returns the letter grade
public char getGrade()
{
//Return the value
return grade;
}
//Define a set method that takes the course ID
public void setID(String idNum)
{
//Assign the value
courseID = idNum;
}
//Define a set method that takes the credit hours
public void setCredits(int cr)
{
//Assign the value
credits = cr;
}
//Define a set method that takes the letter grade
public void setGrade(char gr)
{
//Assign the value
grade = gr;
}
}
File name: “Student...
b.
Explanation of Solution
Program:
File name: “InputGrades.java”
//Import necessary header files
import college.CollegeCourse;
import college.Student;
import javax.swing.*;
//Define a class named InputGrades
public class InputGrades
{
//Define a main method
public static void main(String[] args)
{
//Declare an array to store data of 10 students
Student[] students = new Student[10];
//Declare the variables and initialize the values
int x, y, z;
String courseEntry, entry = "", message;
int idEntry, credits;
char gradeEntry = ' ';
boolean isGoodGrade = false;
final int NUM_COURSES = 5;
//Declare an array to store five grades
char[] grades = {'A', 'B', 'C', 'D', 'F'};
//For loop to be executed until x exceeds 10
for(x = 0; x < students.length; ++x)
{
//Create a student object
Student stu = new Student();
//Prompt the user to enter the student ID
entry = JOptionPane.showInputDialog(null, "For student #" +
(x + 1) + ", enter the student ID");
idEntry = Integer.parseInt(entry);
//Function call
stu.setID(idEntry);
//For loop to be executed until y exceeds 5
for(y = 0; y < NUM_COURSES; ++y)
{
//Prompt the user to enter the course
courseEntry = JOptionPane.showInputDialog(null,
"For student #" + (x + 1) + ", enter course #" +
(y + 1));
//Prompt the user to enter the credits for each //course
entry = JOptionPane.showInputDialog(null,
"For student #" + (x + 1) +
", enter credits for course #" + (y + 1));
credits = Integer.parseInt(entry);
//Assign the value false to isGoodGrade
isGoodGrade = false;
//While the user does not enter isGoodGrade
while(!isGoodGrade)
{
//Prompt the user to enter the grade for //course
entry = JOptionPane.showInputDialog(null,
"For student #" + (x + 1) +
", enter grade for course #" + (y + 1));
gradeEntry = entry...
Trending nowThis is a popular solution!
Chapter 8 Solutions
MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
- This is the question I am stuck on - A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer argument and returns the CollegeCourse in that position (0 through 4). Next, create a set method that sets the value of one of the Student’s CollegeCourse objects; the method takes two arguments—a CollegeCourse and an integer representing the CollegeCourse’s position (0 through 4). B. Write an application that prompts a professor to enter grades for five different courses each for 10 students. Prompt the professor to enter data for one student at a time, including student ID and course data for…arrow_forwardCreate a BowlingTeam class The class has 2 fields: a field for the team name and an array that holds the team members’ names. Create get and set methods for the teamName field. Add a setMember method that sets a team member’s name. The method requires a position and a name, and it uses the position as a subscript to the members array. Add a getMember method that returns a team member’s name. The method requires a value used as a subscript that determines which member’s name to return. Create a BowlingTeamDemo class. In the main method include the following: Declare 2 variables: name and a constant NUM_TEAMS that holds 4 Bowling Team objects. Declare and instantiate an array teams of BowlingTeam objects. Using nested for loops, prompt the user to enter the 4 team names and enter the team members’ names. Using another nested for loop, output each team’s name and their team members’. Output should look like: Members of team The Lucky Strikes Carlos Diego Rose Lynn Members of team I…arrow_forwarduse this code template to help you continue: private boolean included Indicates whether the item should be taken or not public Item(String name, double weight, int value) Initializes the Item’s fields to the values that are passed in; the included Field is initialized to false public Item(Item other) Initializes this item’s fields to the be the same as the other item’s public void setIncluded(boolean included) Setter for the item’s included field (you don’t need setters for the other fields) Given code: public class Item { private final String name; private final double weight; private final int value; public Item(String name, double weight, int value) { this.name = name; this.weight = weight; this.value = value; } static int max(int a, int b) { if(a > b) return a; return b; } // function to print the items which are taken static void printSelection(int W, Item[] items, int…arrow_forward
- Complete the following tasks: Design a class named StockTransaction that holds a stock symbol (typically one to four characters), stock name, and price per share. Include methods to set and get the values for each data field. Create the class diagram and write the pseudocode that defines the class. Design an application that declares two StockTransaction objects and sets and displays their values. Design an application that declares an array of 10 StockTransactionobjects. Prompt the user for data for each object, and then display all the values. Design an application that declares an array of 10 StockTransactionobjects. Prompt the user for data for each object, and then pass the array to a method that determines and displays the two stocks with the highest and lowest price per share.arrow_forwardIn python, complete both sections please Section 5: The StudentAccount class This class represents a financial status of the student based on enrollment and is saved to a Student object as an attribute. This class should also contain an attribute that stores the price per credit, initially $1000/credit. This cost can change at any time and should affect the future price of enrollment for ALL students. Attributes Type Name Description Student student The Student object that owns this StudentAccount. numerical balance The balance that the student has to pay. dict loans A dictionary that stores Loan objects accessible by their loan_id. Methods Type Name Description numerical makePayment(self, amount) Makes a payment towards the balance. numerical chargeAccount(self, amount) Adds an amount towards the balance. Special methods Type Name Description str __str__(self) Returns a formatted summary of the loan as a string. str __repr__(self) Returns the same formatted summary as __str__.…arrow_forwardDon't put incorrect code..arrow_forward
- Complete the following tasks:a. Design a class named AutomobileLoan that holds a loan number, make and model of automobile, and balance. Include methods to set values for each data field and a method that displays all the loan information. Create the class diagram and write the pseudocode that defines the class.b. Design an application that declares two AutomobileLoan objects and sets and displays their values.c. Design an application that declares an array of 20 AutomobileLoan objects. Prompt the user for data for each object, and then display all the values.d. Design an application that declares an array of 20 AutomobileLoan objects. Prompt the user for data for each object, and then pass the array to a method that determines the sum of the balances.arrow_forwardIntroduction In this project, you will complete a C++ class by writing a copy constructor, destructor, and assignment operator. Furthermore, you will write a tester class and a test program and use Valgrind to check that your program is free of memory leaks. Finally, you will submit your project files on GL. If you have submitted programs on GL using shared directories (instead of the submit command), then the submission steps should be familiar. In this project we develop an application which holds the information about a digital art piece. There are two classes in this project. • The Random class generates data. The implementation of this class is provided. It generates random int numbers for colors. To create an object of this class we need to specify min and max values for the constructor. The colors fall between 30 and 37 inclusively. The Art class generates random colors and stores the color values. You implement the Art class. An object of the Art class is a digital masterpiece.…arrow_forwarddesign a Club class and use it to create an application that simulates asoccer league tournament. You are not limited to the features included in these instructionsDesign the Club class, to be used in your application, containing: A private data member code of type string that holds the three letters club’s abbreviation(ex, FCB, LIV, RAM ...) A private data member name of type string that holds the club’s name (ex, FC Barcelona,Liverpool, Real Madrid …) A private data member round of type integer that holds the number of rounds the club hasplayed so far in the current league. A private data member wins of type integer that holds the number of times the club haswon in the current league. A private data member draws of type integer that holds the number of times the club hasbeen drawn in the current league. A private data member losses of type integer that holds the number of times the club haslost in the current league. A private data member goals of type integer that holds the…arrow_forward
- Create a Student class that have two data members id (assign to your ID) and name (assign to your name). Create the object of the Student class by new keyword and printing the objects value. You may name your object as Student1. The output should be like this: 20170500 Asma Zubaidaarrow_forwardCreate a class named Salesperson. Data fields for Salesperson include an integer ID number and a double annual sales amount. Methods include a constructor that requires values for both data fields, as well as get and set methods for each of the data fields. Write an application named DemoSalesperson that declares an array of 10 Salesperson objects. Set each ID number to 9999 and each sales value to zero. Display the 10 Salesperson objects.arrow_forwardCreate the StockTask1 Java project Create a Stock object class that contains the following information: The symbol of the stock is stored in a private string data field called symbol. The stock's name is stored in a private string data field called name. previousClosingPrice is a private double data area that stores the stock price for the previous day. currentPrice is a private double data area that stores the stock price at the current time. A constructor for creating a stock with the given symbol and name. For the data fields, there are accessor methods (get-methods). For the data fields, there is a mutator method (set-methods). A method named getChangePercent()that returns the percentage changed from previousClosingPrice to currentPrice. Formula:perc_change = (current price - previous closing price) / previous closing price x 100 Create a test class named testStockthat creates a Stockobject with the stock symbol SUNW, the name Sun Microsystems Inc., and the previous closing…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning