Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › *sigh* Another Java Assignment
New Posts  All Forums:Forum Nav:

*sigh* Another Java Assignment

post #1 of 10
Thread Starter 
OK, just need some help understanding my teachers directions; here's what is stated:
Quote:
Declare four String type variables, and assign them values as follows (write four separate instructions, one per variable. Each instruction must declare AND initialize the variable at the same time):

courseID1 = "CS101"
courseID2 = "CS102"
courseID3 = "CS103"
courseID4 = "CS104"

Declare four char type variables called 'studentGrade1', 'studentGrade2', 'studentGrade3', and 'studentGrade4' all in a single statement (in other words, one semi-colon only for all 4). DO NOT initialize them while declaring. Instead write 4 additional statements that set values of the 4 grades as follows:

studentGrade1 = 'A'
studentGrade2 = 'B'
studentGrade3 = 'A'
studentGrade4 = 'B'

Declare four 'double' type variables called 'gradePoints1', 'gradePoints2', 'gradePoints3', and 'gradePoints4', all in a single statement (in other words, one semi-colon only for all 4), and also intiailize them on that statement, with following values:

gradePoints1 = 4.0
gradePoints2 = 3.0
gradePoints3 = 4.0
gradePoints4 = 3.0

I have the parts that are confusing me bolded. I believe I have the first one completed correctly, I have it like this:
Code:
             String courseID1 = "CS101";
                String courseID2 = "CS102";
                String courseID3 = "CS103";
                String courseID4 = "CS104";

But for the other two, I'm kind of lost...I'll post what I have, can someone help me understand what the assignment means by using a single semi-colon for all four variables?
Code:
                char studentGrade1 = 'A';
                char studentGrade2 = 'B';
                char studentGrade3 = 'A';
                char studentGrade4 = 'B';
 
Work Lappy
(4 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i7 960 P6T NVIDIA GeForce GTX 560 Ti NVIDIA GeForce GTX 560 Ti 
RAMRAMRAMHard Drive
G.Skill DDR3 G.Skill DDR3 G.Skill DDR3 OCZ Vertex 3 SSD 
Hard DriveOptical DriveCoolingOS
WD Backup Lite-On DVD Corsair H80 Windows 7 Pro 
KeyboardPowerCaseMouse
Logitech G15 v2 OCZ ModXStream Pro 700W Antec 300 Logitech g5 
Mouse PadAudio
Ratpad Razer Barracuda AC-1 
CPUMotherboardGraphicsRAM
Intel Core i5 0JGC48 Intel(R) HD Graphics Family Micron Technology  
  hide details  
Reply
 
Work Lappy
(4 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i7 960 P6T NVIDIA GeForce GTX 560 Ti NVIDIA GeForce GTX 560 Ti 
RAMRAMRAMHard Drive
G.Skill DDR3 G.Skill DDR3 G.Skill DDR3 OCZ Vertex 3 SSD 
Hard DriveOptical DriveCoolingOS
WD Backup Lite-On DVD Corsair H80 Windows 7 Pro 
KeyboardPowerCaseMouse
Logitech G15 v2 OCZ ModXStream Pro 700W Antec 300 Logitech g5 
Mouse PadAudio
Ratpad Razer Barracuda AC-1 
CPUMotherboardGraphicsRAM
Intel Core i5 0JGC48 Intel(R) HD Graphics Family Micron Technology  
  hide details  
Reply
post #2 of 10
Quote:
Originally Posted by Krunk_Kracker View Post

OK, just need some help understanding my teachers directions; here's what is stated:
Quote:
Declare four String type variables, and assign them values as follows (write four separate instructions, one per variable. Each instruction must declare AND initialize the variable at the same time):
courseID1 = "CS101"
courseID2 = "CS102"
courseID3 = "CS103"
courseID4 = "CS104"
Declare four char type variables called 'studentGrade1', 'studentGrade2', 'studentGrade3', and 'studentGrade4' all in a single statement (in other words, one semi-colon only for all 4). DO NOT initialize them while declaring. Instead write 4 additional statements that set values of the 4 grades as follows:
studentGrade1 = 'A'
studentGrade2 = 'B'
studentGrade3 = 'A'
studentGrade4 = 'B'
Declare four 'double' type variables called 'gradePoints1', 'gradePoints2', 'gradePoints3', and 'gradePoints4', all in a single statement (in other words, one semi-colon only for all 4), and also intiailize them on that statement, with following values:
gradePoints1 = 4.0
gradePoints2 = 3.0
gradePoints3 = 4.0
gradePoints4 = 3.0
I have the parts that are confusing me bolded. I believe I have the first one completed correctly, I have it like this:
Code:
             String courseID1 = "CS101";
                String courseID2 = "CS102";
                String courseID3 = "CS103";
                String courseID4 = "CS104";
But for the other two, I'm kind of lost...I'll post what I have, can someone help me understand what the assignment means by using a single semi-colon for all four variables?
Code:
                char studentGrade1 = 'A';
                char studentGrade2 = 'B';
                char studentGrade3 = 'A';
                char studentGrade4 = 'B';

Hi, you should really check out this guys' channel on Youtube. Watch a few videos and then try this assignment. It'll actually take you less time to finish this wink.gif:

Bucky's Java for beginners, intermediate, and game development.

The point is that you just need to get the hang of programming in general, the terms and syntax. He explains it good and very quick so it definately won't be boring.

As for the questions:

The first one is correct.

Then the second one
Declare four char type variables called 'studentGrade1', 'studentGrade2', 'studentGrade3', and 'studentGrade4' all in a single statement (in other words, one semi-colon only for all 4). DO NOT initialize them while declaring. Instead write 4 additional statements that set values of the 4 grades as follows:

He wants you to declare variables of the type char all in one statement without giving them a value in the beginning (actually you're doing the complete opposite tongue.gif). You declare the variables in 4 statements and do in fact initialize them immediately.

In the last one he asks you to declare the variables in one statement just as above, but this time you must give them a value at moment you declare them. So you have to do all he says with only one semicolon wink.gif

So, let's say I want to assign a number to some letters and initializing them using only 1 statement.
Code:
int a = 1, b = 2, c = 3, d = 4, e = 5, f = 6;

That's basically what he wants you to do. Although this is in C/C++ syntax I don't think it will give you errors in Java but keep it in mind. Either way the prinicple remains the same wink.gif
post #3 of 10
Thread Starter 
Quote:
Originally Posted by TheBlademaster01 View Post

Hi, you should really check out this guys' channel on Youtube. Watch a few videos and then try this assignment. It'll actually take you less time to finish this wink.gif:
Bucky's Java for beginners, intermediate, and game development.
The point is that you just need to get the hang of programming in general, the terms and syntax. He explains it good and very quick so it definately won't be boring.
As for the questions:
The first one is correct.
Then the second one
Declare four char type variables called 'studentGrade1', 'studentGrade2', 'studentGrade3', and 'studentGrade4' all in a single statement (in other words, one semi-colon only for all 4). DO NOT initialize them while declaring. Instead write 4 additional statements that set values of the 4 grades as follows:
He wants you to declare variables of the type char all in one statement without giving them a value in the beginning (actually you're doing the complete opposite tongue.gif). You declare the variables in 4 statements and do in fact initialize them immediately.
In the last one he asks you to declare the variables in one statement just as above, but this time you must give them a value at moment you declare them. So you have to do all he says with only one semicolon wink.gif
So, let's say I want to assign a number to some letters and initializing them using only 1 statement.
Code:
int a = 1, b = 2, c = 3, d = 4, e = 5, f = 6;
That's basically what he wants you to do. Although this is in C/C++ syntax I don't think it will give you errors in Java but keep it in mind. Either way the prinicple remains the same wink.gif

I used thenewboston's Android developing tutorials, he is very good. His Java classes were throwing me for a loop though, so I'm taking this course right now. I've already paid for this, so I'm not gonna skip it smile.gif

Anyways, I think I got all the variables declared correctly.
Code:
class Student
{
    public static void main(String[] args)
    {
                int studentID = 101; 
                String firstName = "John";
                String lastName = "Smith";
                String courseID1 = "CS101";
                String courseID2 = "CS102";
                String courseID3 = "CS103";
                String courseID4 = "CS104";
                
                char studentGrade1, studentGrade2, studentGrade3, studentGrade4;
                studentGrade1 = 'A';
                studentGrade2 = 'B';
                studentGrade3 = 'A';
                studentGrade4 = 'B';
                
                double gradePoints1 = 4.0, gradePoints2 = 3.0, gradePoint3 = 4.0, gradePoint = 3.0;
                
                
    }
}

So now I just need to work on the output.
Edited by Krunk_Kracker - 2/4/12 at 7:07am
 
Work Lappy
(4 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i7 960 P6T NVIDIA GeForce GTX 560 Ti NVIDIA GeForce GTX 560 Ti 
RAMRAMRAMHard Drive
G.Skill DDR3 G.Skill DDR3 G.Skill DDR3 OCZ Vertex 3 SSD 
Hard DriveOptical DriveCoolingOS
WD Backup Lite-On DVD Corsair H80 Windows 7 Pro 
KeyboardPowerCaseMouse
Logitech G15 v2 OCZ ModXStream Pro 700W Antec 300 Logitech g5 
Mouse PadAudio
Ratpad Razer Barracuda AC-1 
CPUMotherboardGraphicsRAM
Intel Core i5 0JGC48 Intel(R) HD Graphics Family Micron Technology  
  hide details  
Reply
 
Work Lappy
(4 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i7 960 P6T NVIDIA GeForce GTX 560 Ti NVIDIA GeForce GTX 560 Ti 
RAMRAMRAMHard Drive
G.Skill DDR3 G.Skill DDR3 G.Skill DDR3 OCZ Vertex 3 SSD 
Hard DriveOptical DriveCoolingOS
WD Backup Lite-On DVD Corsair H80 Windows 7 Pro 
KeyboardPowerCaseMouse
Logitech G15 v2 OCZ ModXStream Pro 700W Antec 300 Logitech g5 
Mouse PadAudio
Ratpad Razer Barracuda AC-1 
CPUMotherboardGraphicsRAM
Intel Core i5 0JGC48 Intel(R) HD Graphics Family Micron Technology  
  hide details  
Reply
post #4 of 10
Thread Starter 
This assignment is coming along MUCH easier for me. I've got a lot of working code now, I'm just not sure how to get it to conform to the format the teacher expects, I'll post the assignment and bold the portions that I'm talking about.
Quote:
Note: This assignment carries a 3% weight in the overall score. You need to submit your response to this assignment by pasting your code in the box below and clicking on Submit. You can submit your assignment only once so make sure it compiles and runs fine on your machine before submitting.
Objective: To learn how to declare variables of various types, concatenate String values and to display the result.
Steps:
Create a new folder called 'assign22' under C:\Java\Lesson2. Copy HelloWorld.java from Lesson 1 into it, and rename the file to "Student.java". Replace the word "HelloWorld" with "Student". Replace the System.out line with instructions to declare variables, and display output as described below:

Write a comment that says "Declare and intialize variables".

On the next line, declare a variable of type int, called studentID, and initialize it to a value of 101.

Declare another variable of type String, called firstName, and initialize with a value of "John". Similarly, declare a String variable called 'lastName' with a value of "Smith".

Declare four String type variables, and assign them values as follows (write four separate instructions, one per variable. Each instruction must declare AND initialize the variable at the same time):

courseID1 = "CS101"
courseID2 = "CS102"
courseID3 = "CS103"
courseID4 = "CS104"

Declare four char type variables called 'studentGrade1', 'studentGrade2', 'studentGrade3', and 'studentGrade4' all in a single statement (in other words, one semi-colon only for all 4). DO NOT initialize them while declaring. Instead write 4 additional statements that set values of the 4 grades as follows:

studentGrade1 = 'A'
studentGrade2 = 'B'
studentGrade3 = 'A'
studentGrade4 = 'B'

Declare four 'double' type variables called 'gradePoints1', 'gradePoints2', 'gradePoints3', and 'gradePoints4', all in a single statement (in other words, one semi-colon only for all 4), and also intiailize them on that statement, with following values:

gradePoints1 = 4.0
gradePoints2 = 3.0
gradePoints3 = 4.0
gradePoints4 = 3.0

Write a comment that says "Compute the GPA".

Declare a 'double' type variable called 'gpa' and assign it the average of the 4 grade values, so:

gpa = (gradePoints1 + gradePoints2 + gradePoints3 + gradePoints4)/4

Write a comment that says "Display the output".

Using the above variables and their values, display the final result as follows. Try to align the data with the headers. DO NOT "hard-code" the values but instead use the variables and concatenate with appropriate labels using the + operator. Points will be deducted if hard-coded values are used.

Code:
Student ID: 101
   First Name: John
   Last Name: Smith
   Grades:
        
--------------------------------------------------------
Course  Grade   Points
--------------------------------------------------------
CS101   A       4.0
CS102   B       3.0
CS103   A       4.0
CS104   B       3.0
--------------------------------------------------------
           GPA: 3.5
--------------------------------------------------------[/B]

I'm not sure how to get the output to look like that table format. Thoughts? Here is my code so far:
Code:
class Student
{
    public static void main(String[] args)
    {
                int studentID = 101; 
                String firstName = "John";
                String lastName = "Smith";
                String courseID1 = "CS101";
                String courseID2 = "CS102";
                String courseID3 = "CS103";
                String courseID4 = "CS104";
                
                char studentGrade1, studentGrade2, studentGrade3, studentGrade4;
                studentGrade1 = 'A';
                studentGrade2 = 'B';
                studentGrade3 = 'A';
                studentGrade4 = 'B';
                
                double gradePoints1 = 4.0, gradePoints2 = 3.0, gradePoints3 = 4.0, gradePoints4 = 3.0;
                
                //Compute the GPA
                double gpa = (gradePoints1 + gradePoints2 + gradePoints3 + gradePoints4)/4;
                
                //Display the output
                System.out.println("Student ID: " + studentID);
                System.out.println("First Name: " + firstName);
                System.out.println("Last Name: " + lastName);
                System.out.println("Grades:");
    }
}

:EDIT:

This is all starting to REALLY come to me, after I stop thinking inside the box and allowed myself to get creative. I may not need help after all. Here is where I am now:
Code:
class Student
{
    public static void main(String[] args)
    {
                int studentID = 101; 
                String firstName = "John";
                String lastName = "Smith";
                String courseID1 = "CS101";
                String courseID2 = "CS102";
                String courseID3 = "CS103";
                String courseID4 = "CS104";
                
                char studentGrade1, studentGrade2, studentGrade3, studentGrade4;
                studentGrade1 = 'A';
                studentGrade2 = 'B';
                studentGrade3 = 'A';
                studentGrade4 = 'B';
                
                double gradePoints1 = 4.0, gradePoints2 = 3.0, gradePoints3 = 4.0, gradePoints4 = 3.0;
                
                //Compute the GPA
                double gpa = (gradePoints1 + gradePoints2 + gradePoints3 + gradePoints4)/4;
                
                //Display the output
                System.out.println("Student ID: " + studentID);
                System.out.println("   First Name: " + firstName);
                System.out.println("   Last Name: " + lastName);
                System.out.println("   Grades:");
                System.out.println(" ");
                System.out.println("-----------------------------------");
                System.out.println("Course  Grade  Points");
                System.out.println("-----------------------------------");
                System.out.println("");
    }
}

Edited by Krunk_Kracker - 2/4/12 at 7:22am
 
Work Lappy
(4 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i7 960 P6T NVIDIA GeForce GTX 560 Ti NVIDIA GeForce GTX 560 Ti 
RAMRAMRAMHard Drive
G.Skill DDR3 G.Skill DDR3 G.Skill DDR3 OCZ Vertex 3 SSD 
Hard DriveOptical DriveCoolingOS
WD Backup Lite-On DVD Corsair H80 Windows 7 Pro 
KeyboardPowerCaseMouse
Logitech G15 v2 OCZ ModXStream Pro 700W Antec 300 Logitech g5 
Mouse PadAudio
Ratpad Razer Barracuda AC-1 
CPUMotherboardGraphicsRAM
Intel Core i5 0JGC48 Intel(R) HD Graphics Family Micron Technology  
  hide details  
Reply
 
Work Lappy
(4 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i7 960 P6T NVIDIA GeForce GTX 560 Ti NVIDIA GeForce GTX 560 Ti 
RAMRAMRAMHard Drive
G.Skill DDR3 G.Skill DDR3 G.Skill DDR3 OCZ Vertex 3 SSD 
Hard DriveOptical DriveCoolingOS
WD Backup Lite-On DVD Corsair H80 Windows 7 Pro 
KeyboardPowerCaseMouse
Logitech G15 v2 OCZ ModXStream Pro 700W Antec 300 Logitech g5 
Mouse PadAudio
Ratpad Razer Barracuda AC-1 
CPUMotherboardGraphicsRAM
Intel Core i5 0JGC48 Intel(R) HD Graphics Family Micron Technology  
  hide details  
Reply
post #5 of 10
Quote:
Originally Posted by Krunk_Kracker View Post

This assignment is coming along MUCH easier for me. I've got a lot of working code now, I'm just not sure how to get it to conform to the format the teacher expects, I'll post the assignment and bold the portions that I'm talking about.
Quote:
Note: This assignment carries a 3% weight in the overall score. You need to submit your response to this assignment by pasting your code in the box below and clicking on Submit. You can submit your assignment only once so make sure it compiles and runs fine on your machine before submitting.
Objective: To learn how to declare variables of various types, concatenate String values and to display the result.
Steps:
Create a new folder called 'assign22' under C:\Java\Lesson2. Copy HelloWorld.java from Lesson 1 into it, and rename the file to "Student.java". Replace the word "HelloWorld" with "Student". Replace the System.out line with instructions to declare variables, and display output as described below:
Write a comment that says "Declare and intialize variables".
On the next line, declare a variable of type int, called studentID, and initialize it to a value of 101.
Declare another variable of type String, called firstName, and initialize with a value of "John". Similarly, declare a String variable called 'lastName' with a value of "Smith".
Declare four String type variables, and assign them values as follows (write four separate instructions, one per variable. Each instruction must declare AND initialize the variable at the same time):
courseID1 = "CS101"
courseID2 = "CS102"
courseID3 = "CS103"
courseID4 = "CS104"
Declare four char type variables called 'studentGrade1', 'studentGrade2', 'studentGrade3', and 'studentGrade4' all in a single statement (in other words, one semi-colon only for all 4). DO NOT initialize them while declaring. Instead write 4 additional statements that set values of the 4 grades as follows:
studentGrade1 = 'A'
studentGrade2 = 'B'
studentGrade3 = 'A'
studentGrade4 = 'B'
Declare four 'double' type variables called 'gradePoints1', 'gradePoints2', 'gradePoints3', and 'gradePoints4', all in a single statement (in other words, one semi-colon only for all 4), and also intiailize them on that statement, with following values:
gradePoints1 = 4.0
gradePoints2 = 3.0
gradePoints3 = 4.0
gradePoints4 = 3.0
Write a comment that says "Compute the GPA".
Declare a 'double' type variable called 'gpa' and assign it the average of the 4 grade values, so:
gpa = (gradePoints1 + gradePoints2 + gradePoints3 + gradePoints4)/4
Write a comment that says "Display the output".
Using the above variables and their values, display the final result as follows. Try to align the data with the headers. DO NOT "hard-code" the values but instead use the variables and concatenate with appropriate labels using the + operator. Points will be deducted if hard-coded values are used.
Code:
Student ID: 101
   First Name: John
   Last Name: Smith
   Grades:
        
--------------------------------------------------------
Course  Grade   Points
--------------------------------------------------------
CS101   A       4.0
CS102   B       3.0
CS103   A       4.0
CS104   B       3.0
--------------------------------------------------------
           GPA: 3.5
--------------------------------------------------------[/B]
I'm not sure how to get the output to look like that table format. Thoughts? Here is my code so far:
Code:
class Student
{
    public static void main(String[] args)
    {
                int studentID = 101; 
                String firstName = "John";
                String lastName = "Smith";
                String courseID1 = "CS101";
                String courseID2 = "CS102";
                String courseID3 = "CS103";
                String courseID4 = "CS104";
                
                char studentGrade1, studentGrade2, studentGrade3, studentGrade4;
                studentGrade1 = 'A';
                studentGrade2 = 'B';
                studentGrade3 = 'A';
                studentGrade4 = 'B';
                
                double gradePoints1 = 4.0, gradePoints2 = 3.0, gradePoints3 = 4.0, gradePoints4 = 3.0;
                
                //Compute the GPA
                double gpa = (gradePoints1 + gradePoints2 + gradePoints3 + gradePoints4)/4;
                
                //Display the output
                System.out.println("Student ID: " + studentID);
                System.out.println("First Name: " + firstName);
                System.out.println("Last Name: " + lastName);
                System.out.println("Grades:");
    }
}
:EDIT:
This is all starting to REALLY come to me, after I stop thinking inside the box and allowed myself to get creative. I may not need help after all. Here is where I am now:
Code:
class Student
{
    public static void main(String[] args)
    {
                int studentID = 101; 
                String firstName = "John";
                String lastName = "Smith";
                String courseID1 = "CS101";
                String courseID2 = "CS102";
                String courseID3 = "CS103";
                String courseID4 = "CS104";
                
                char studentGrade1, studentGrade2, studentGrade3, studentGrade4;
                studentGrade1 = 'A';
                studentGrade2 = 'B';
                studentGrade3 = 'A';
                studentGrade4 = 'B';
                
                double gradePoints1 = 4.0, gradePoints2 = 3.0, gradePoints3 = 4.0, gradePoints4 = 3.0;
                
                //Compute the GPA
                double gpa = (gradePoints1 + gradePoints2 + gradePoints3 + gradePoints4)/4;
                
                //Display the output
                System.out.println("Student ID: " + studentID);
                System.out.println("   First Name: " + firstName);
                System.out.println("   Last Name: " + lastName);
                System.out.println("   Grades:");
                System.out.println(" ");
                System.out.println("-----------------------------------");
                System.out.println("Course  Grade  Points");
                System.out.println("-----------------------------------");
                System.out.println("");
    }
}

Lol that's creative, I don't think there's another option either.

I wouldn't have thought about that tongue.gif
post #6 of 10
I think you are getting along just fine and that format for the display is fine too, I think.

Just a suggestion:

You may want to post programming related questions in the Coding and Programming section in the future. You'll get more help probably.
MacBook Pro 13"
(6 items)
 
 
Desktop
(13 items)
 
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
  hide details  
Reply
MacBook Pro 13"
(6 items)
 
 
Desktop
(13 items)
 
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
  hide details  
Reply
post #7 of 10
Thread Starter 
Quote:
Originally Posted by TheBlademaster01 View Post

Lol that's creative, I don't think there's another option either.
I wouldn't have thought about that tongue.gif

What's creative about it? Haha
Quote:
Originally Posted by {Unregistered} View Post

I think you are getting along just fine and that format for the display is fine too, I think.
Just a suggestion:
You may want to post programming related questions in the Coding and Programming section in the future. You'll get more help probably.

Good idea, I'll do so.

Oh look, I'm a mod...won't be a problem to move this thing wink.gif
Edited by Krunk_Kracker - 2/4/12 at 8:43pm
 
Work Lappy
(4 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i7 960 P6T NVIDIA GeForce GTX 560 Ti NVIDIA GeForce GTX 560 Ti 
RAMRAMRAMHard Drive
G.Skill DDR3 G.Skill DDR3 G.Skill DDR3 OCZ Vertex 3 SSD 
Hard DriveOptical DriveCoolingOS
WD Backup Lite-On DVD Corsair H80 Windows 7 Pro 
KeyboardPowerCaseMouse
Logitech G15 v2 OCZ ModXStream Pro 700W Antec 300 Logitech g5 
Mouse PadAudio
Ratpad Razer Barracuda AC-1 
CPUMotherboardGraphicsRAM
Intel Core i5 0JGC48 Intel(R) HD Graphics Family Micron Technology  
  hide details  
Reply
 
Work Lappy
(4 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i7 960 P6T NVIDIA GeForce GTX 560 Ti NVIDIA GeForce GTX 560 Ti 
RAMRAMRAMHard Drive
G.Skill DDR3 G.Skill DDR3 G.Skill DDR3 OCZ Vertex 3 SSD 
Hard DriveOptical DriveCoolingOS
WD Backup Lite-On DVD Corsair H80 Windows 7 Pro 
KeyboardPowerCaseMouse
Logitech G15 v2 OCZ ModXStream Pro 700W Antec 300 Logitech g5 
Mouse PadAudio
Ratpad Razer Barracuda AC-1 
CPUMotherboardGraphicsRAM
Intel Core i5 0JGC48 Intel(R) HD Graphics Family Micron Technology  
  hide details  
Reply
post #8 of 10
Quote:
Originally Posted by Krunk_Kracker View Post

What's creative about it? Haha
Good idea, I'll do so.
Oh look, I'm a mod...won't be a problem to move this thing wink.gif

The fact that you printed the empty spaces and dashes, I didn't really understand the question before you came up with that code tongue.gif

Almost looks like your're applying ASCII art.
post #9 of 10
How I would do the rest of the assignment personally would be to make a method entitled courseReport or courseLine or something and pass through the variables (string course, string grade, and double points) and then make it print out "course + " " + grade + " " + points" depending on what values you pass through. I think that would be better than just printing out the variables in 3 println lines because it's now customizable. If you don't have to do that I think println's would be fine.
Edited by tombom - 2/5/12 at 1:51am
HAF 912 Rig
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel 3570k delid Gigabyte Z77-D3H Galaxy GTX 680 Kingston Hyper X 4x2GB 
Hard DriveHard DriveCoolingOS
Toshiba 2TB HDD 90GB Corsair Force 3 H70 w/ push/pull panaflo W7 ult. 64 bit 
MonitorKeyboardPowerCase
BenQ XL2420T w/ lighboost hack 24/7 Coolermaster Quickfire with Cherry Browns Rosewill HIVE 750w Coolermaster HAF912 
MouseMouse PadAudio
Windows Mouse Optical Puretrak Talent Fiio E7 > Denon AHD2000 
  hide details  
Reply
HAF 912 Rig
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel 3570k delid Gigabyte Z77-D3H Galaxy GTX 680 Kingston Hyper X 4x2GB 
Hard DriveHard DriveCoolingOS
Toshiba 2TB HDD 90GB Corsair Force 3 H70 w/ push/pull panaflo W7 ult. 64 bit 
MonitorKeyboardPowerCase
BenQ XL2420T w/ lighboost hack 24/7 Coolermaster Quickfire with Cherry Browns Rosewill HIVE 750w Coolermaster HAF912 
MouseMouse PadAudio
Windows Mouse Optical Puretrak Talent Fiio E7 > Denon AHD2000 
  hide details  
Reply
post #10 of 10
Thread Starter 
Quote:
Originally Posted by tombom View Post

How I would do the rest of the assignment personally would be to make a method entitled courseReport or courseLine or something and pass through the variables (string course, string grade, and double points) and then make it print out "course + " " + grade + " " + points" depending on what values you pass through. I think that would be better than just printing out the variables in 3 println lines because it's now customizable. If you don't have to do that I think println's would be fine.

Thanks for your input!

During my Googling for help, I came across the use of methods, but since we have not yet learned about methods, I don't think it would be a good idea to create the program using them. That said, I think I got it all figured out per the curriculum smile.gif
Code:
class Student
{
    public static void main(String[] args)
    {
                int studentID = 101; 
                String firstName = "John";
                String lastName = "Smith";
                String courseID1 = "CS101";
                String courseID2 = "CS102";
                String courseID3 = "CS103";
                String courseID4 = "CS104";
                
                char studentGrade1, studentGrade2, studentGrade3, studentGrade4;
                studentGrade1 = 'A';
                studentGrade2 = 'B';
                studentGrade3 = 'A';
                studentGrade4 = 'B';
                
                double gradePoints1 = 4.0, gradePoints2 = 3.0, gradePoints3 = 4.0, gradePoints4 = 3.0;
                
                //Compute the GPA
                double gpa = (gradePoints1 + gradePoints2 + gradePoints3 + gradePoints4)/4;
                
                //Display the output
                System.out.println("Student ID: " + studentID);
                System.out.println("First Name: " + firstName);
                System.out.println("Last Name: " + lastName);
                System.out.println("Grades:");
                System.out.println(" ");
                System.out.println("---------------------------------");
                System.out.println("Course      Grade      Points");
                System.out.println("---------------------------------");
                System.out.println(courseID1 + "         " + studentGrade1 + "         " + gradePoints1);
                System.out.println(courseID2 + "         " + studentGrade2 + "         " + gradePoints2);
                System.out.println(courseID3 + "         " + studentGrade3 + "         " + gradePoints3);
                System.out.println(courseID4 + "         " + studentGrade4 + "         " + gradePoints4);
                System.out.println("---------------------------------");
                System.out.println("   GPA: " + gpa);
                System.out.println("---------------------------------");
    }
}
 
Work Lappy
(4 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i7 960 P6T NVIDIA GeForce GTX 560 Ti NVIDIA GeForce GTX 560 Ti 
RAMRAMRAMHard Drive
G.Skill DDR3 G.Skill DDR3 G.Skill DDR3 OCZ Vertex 3 SSD 
Hard DriveOptical DriveCoolingOS
WD Backup Lite-On DVD Corsair H80 Windows 7 Pro 
KeyboardPowerCaseMouse
Logitech G15 v2 OCZ ModXStream Pro 700W Antec 300 Logitech g5 
Mouse PadAudio
Ratpad Razer Barracuda AC-1 
CPUMotherboardGraphicsRAM
Intel Core i5 0JGC48 Intel(R) HD Graphics Family Micron Technology  
  hide details  
Reply
 
Work Lappy
(4 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i7 960 P6T NVIDIA GeForce GTX 560 Ti NVIDIA GeForce GTX 560 Ti 
RAMRAMRAMHard Drive
G.Skill DDR3 G.Skill DDR3 G.Skill DDR3 OCZ Vertex 3 SSD 
Hard DriveOptical DriveCoolingOS
WD Backup Lite-On DVD Corsair H80 Windows 7 Pro 
KeyboardPowerCaseMouse
Logitech G15 v2 OCZ ModXStream Pro 700W Antec 300 Logitech g5 
Mouse PadAudio
Ratpad Razer Barracuda AC-1 
CPUMotherboardGraphicsRAM
Intel Core i5 0JGC48 Intel(R) HD Graphics Family Micron Technology  
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › *sigh* Another Java Assignment