First I need to create 2 classes. The first will contain an ID number and an array of 5 course titles. I also have to create a get and a set method for populating the ID. I also must create a method to get a course. It does this by taking an integer and returning the course to that position (0 through 4). Then I must create a set method that sets the value of one of the courses by taking two arguements a name and an integer and returning the name to the position indicated by the integer.
After that I must write an application that prompts the user for grades for 5 different courses: it will prompt for the the id number, then course data for each of 5 courses for that ID number. The user will enter the ID number of the student, then when prompted a number from 1 to 5 indicating which course, and a letter grade for the course.
So far this is what I have: -
// CollegeCourse.java
-
// Chapter 8, Exercise 5a
-
// A CollegeCourse has an ID, credits, and a letter grade
-
-
public class CollegeCourse
-
{
-
private String courseID;
-
private int credits;
-
private char grade;
-
public String getID()
-
{
-
return courseID;
-
}
-
public int getCredits()
-
{
-
return credits;
-
}
-
public char getGrade()
-
{
-
return grade;
-
}
-
public void setID(String idNum)
-
{
-
-
}
-
}
-
-
-
// Student.java
-
// Chapter 8, Exercise 5c
-
// A Student has an ID, and five CoollegeCourses,
-
-
public class Student
-
{
-
private int stuID;
-
private CollegeCourse[] course = new CollegeCourse[5];
-
-
public int getID()
-
{
-
return stuID;
-
}
-
-
*******stuck here***********
-
}
-
}
-
-
// InputGrades.java
-
// Chapter 8, Exercise 5b
-
// Allows input of 5 grades each for 10 students
-
-
import javax.swing.*;
-
public class InputGrades
-
{
-
public static void main(String[] args)
-
{
-
// http://www.brpreiss.com/books/opus5/html/page89.html
-
Student[] students = new Student[10];
-
-
int x, y, z;
-
String courseEntry, entry = "", message;
-
int idEntry, credits;
-
char gradeEntry = ' ';
-
boolean isGoodGrade = false;
-
char[] grades = {'A', 'B', 'C', 'D', 'F'};
-
for(x = 0; x < students.length; ++x)
-
{
-
Student stu = new Student();
-
entry = JOptionPane.showInputDialog(null, "For student #" + (x + 1) + ", enter the student ID");
-
idEntry = Integer.parseInt(entry);
-
stu.setID(idEntry);
-
*********stuck here****************
-
CollegeCourse temp = new CollegeCourse();
-
temp.setID(courseEntry);
-
temp.setCredits(credits);
-
temp.setGrade(gradeEntry);
-
stu.setCourse(temp, y);
-
}
-
students[x] = stu;
-
}
-
for(x = 0; x < students.length; ++x)
-
{
-
message = "Student #" + (x + 1) + " ID #" + students[x].getID();
-
for(y = 0; y < 5; ++y)
-
{
-
CollegeCourse temp = new CollegeCourse();
-
temp = students[x].getCourse(y);
-
message = message + "\n" + temp.getID() + " " + temp.getCredits() + " credits. Grade is " + temp.getGrade();
-
JOptionPane.showMessageDialog(null,message);
-
}
-
System.exit(0);
-
}
-
}
-
}
-
1 3692 pronerd 392
Recognized Expert Contributor Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Radha News |
last post by:
Hi,
I am looking for reference books/tools/code samples for calling java
objects/methods from COM/C++ classes.
I am reasonably familiar with JNI. If you have used JNI, please let me know
of...
|
by: ratedr1 |
last post by:
I am currently trying to label rings (jewelry). They make specialized
tags (shaped like a butterfly, barbell, dumbell, etc) for this purpose,
the label goes through the ring, and then the ends...
|
by: girish.sh |
last post by:
Hi all,
I am using shell scripts which needs to call to few Java classes. Can anyone help me with the information on how to call Java classes/methods from KSH shell scripts.
|
by: glenn123 |
last post by:
Hi, i am just about out of time to produce a working jukebox which has to perform these functions: to play music files when a track is chosen from a list which when the user presses the change genre...
|
by: jgill |
last post by:
Have problems with the recordset…if the value of tempPremium is more than > 10,000 than I get no results after this statement executes:
set rsDownPayment =...
| |
by: jeffbroodwar |
last post by:
Hi everyone,
Please help me accomplish the following :
1. how can i copy a file in java then paste it in a desired location
2. how can i run a .jar file run by just double clicking...
|
by: Newbie19 |
last post by:
I'm just learning java arrays/arraylists and was wondering what are the best books for learning java arrays/arraylists?
I know practice is the best way to learn, but I have a hard time...
|
by: vijay bharath |
last post by:
how to take backup of database using java by query itself? please help
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |