MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
9th Edition
ISBN: 9780357505526
Author: FARRELL
Publisher: CENGAGE L
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 8, Problem 7PE

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...

Blurred answer
Students have asked these similar questions
Create a Database in JAVA OOP that saves name of the player and how many labyrinths did the player solve. Record the number of how many labyrinths did the player solve, and if he loses his life, then save this number together with his name into the database. Create a menu item, which displays a highscore table of the players for the 10 best scores. Also, create a menu item which restarts the game. public class GameGUI extends JPanel {    private final Labyrinth labyrinth;    private final Player player;    private final Dragon dragon;     private void checkGameState() {        if (player.getX() == 0 && player.getY() == labyrinth.getSize() - 1) {            JOptionPane.showMessageDialog(this, "You escaped! Congratulations!");            System.exit(0);        }         if (Math.abs(player.getX() - dragon.getX()) <= 1 &&            Math.abs(player.getY() - dragon.getY()) <= 1) {            JOptionPane.showMessageDialog(this, "The dragon caught you! Game Over.");…
Change the following code so that the player can see only the neighboring fields at a distance of 3 units.   public class GameGUI extends JPanel {    private final Labyrinth labyrinth;    private final Player player;    private final Dragon dragon;     private final ImageIcon playerIcon = new ImageIcon("data/images/player.png");    private final ImageIcon dragonIcon = new ImageIcon("data/images/dragon.png");    private final ImageIcon wallIcon = new ImageIcon("data/images/wall.png");    private final ImageIcon emptyIcon = new ImageIcon("data/images/empty.png");     public GameGUI(Labyrinth labyrinth, Player player, Dragon dragon) {        this.labyrinth = labyrinth;        this.player = player;        this.dragon = dragon;         setFocusable(true);        addKeyListener(new KeyAdapter() {            @Override            public void keyPressed(KeyEvent e) {                char move = switch (e.getKeyCode()) {                    case KeyEvent.VK_W -> 'W';                    case…
Q/ Fill in the table below with the correct answers for the network devices and components required, then draw the topology diagram for the network of this three-story building: I want a drawing Cisco Packet tracer Ground Floor: This floor will house the main server room, reception area, and a few conference rooms. The server room should contain the core network devices that will connect the entire building. The reception area and conference rooms need network access require access for mobile devices for visitors and guests with devices. First Floor: This floor is dedicated to offices with workstations, each needing reliable network connectivity for staff computers, IP phones, IP camera, and printers. Second Floor (Education Department): This floor consists of educational spaces requiring controlled internet access. Only the educational website (https://uokerbala.edu.iq) should be accessible, with all other sites restricted.. Device Media type Location floor Type of IP Static/dynamic…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY