Ilab 2 of 7: Classes, Objects, and Methods(40 Points)

Total Page:16

File Type:pdf, Size:1020Kb

Ilab 2 of 7: Classes, Objects, and Methods(40 Points)

iLab 2 of 7: Classes, Objects, and Methods (40 points) 09:17 AM MT 07/17/2016

Listen

What's this? iLab Overview Scenario/Summary

In this lab, you will create two programs that use classes and methods.

Note!Software Citation Requirements

This course uses open-source software which must be cited when used for any student work. Citation requirements are on the Open Source Applications page. Please review the installation instruction files to complete your assignment

Deliverables

NOTE

Submit your assignment to the Dropbox, located at the top of this page. For instructions on how to use the Dropbox, read these step-by-step instructions.

(See the Syllabus section "Due Dates for Assignments & Exams" for due dates.)

Program files for the following program

1. StudentGPAInfo

2. CurrencyConversion

At the beginning of all your programs, put a comment box that includes the program name, your name, and a brief description of the program.

Example:

/*********************************************************************** Program Name: Classes, Objects, and Methods.java Programmer's Name: Marvin Malone Program Description: Describe here what this program will do ***********************************************************************/

How to submit your assignment:

1. The programs must have the same names as the assignment title.

2. Each Java source file (*.java) must include a corresponding class file (*.class) program as evidence of success.

3. In addition to the program source code files and byte code files, put all your program source code files and screen shots of your program output files into a Word document.

4. You must use a zipped folder to send your weekly assignment to the Dropbox. Do not send subfolders within your zipped folder. Place all of the .java and .class files for the week into the one zipped folder. The zip folder should be named CIS355A_YourLastName_iLab_Week2, and this zip folder will contain all the weekly programming assignments. Required Software

Eclipse

Access the software at https://lab.devry.edu. Steps: 1 and 2 Lab Steps Step 1: StudentGPAInfo (20 points)

You will create a class to store information about a student’s courses and calculate their GPA. Your GPA is based on the class credits and your grade. Each letter grade is assigned a point value as follows:

A = 4 points B = 3 points C = 2 points D = 1 point

Therefore, an A in a 3 unit class is equivalent to 12 grade points (4 for the A times 3 unit class) A C in a 4 unit class is equivalent to 8 grade points (2 for the C times 4 unit class) This is a total of 20 grade points. Your GPA is calculated by dividing the total grade points by the total class credits, so in this case: 20 grade points / 7 credits = 2.85 GPA

Create a class called StudentInfo that represents the following information (private data) about a student:

 Student name

 Total grade points

 Total credits

Create the following public member functions. (Note that the program may not require all functions to be used, but they should all exist for a complete class.)

Default constructor to initialize grade points and credits setName Set value for name getName Returns the name addClass receives as input the class units and grade, updates grade points and credits appropriately getGPA Calculates and returns the GPA displayStudent Displays all info about student. GPA should be displayed with 2 decimal places of precision (i.e., 3.25).

Note that ONLY student name will be “set” from the outside. The grade points and credits will be modified with the method addClass which takes as parameters the number of units for the class and the grade awarded. This method then adds the appropriate grade points to the total, and also adds the credits to the total.

Write a program to test the class as shown below. You should ask for the student’s name, then allow them to add multiple classes. When done, display the GPA. ALL INPUT SHOULD BE RECEIVED IN MAIN AND PASSED TO THE OBJECT. Use console input/output for this program (NOT JOptionPane).

Note that it will be easier to use String for the grade rather than char since Scanner does not have a method to easily return a char.

Sample Output:

Enter Student name: Joe Smith Enter class credits: 3 Enter letter grade: A Another class? y Enter class credits: 4 Enter letter grade: C Another class? n Joe Smith, your GPA is 2.86 Press any key to continue

Grading Rubric

STEP 2: CurrencyConversion (20 points)

You must create a program named CurrencyConversion.java that converts money between the following currencies.

Given one of the three currencies (US Dollar, Yen, Euro), the program should convert the input amount into one of the other currencies. For example, if you input one (1) U.S. dollar, and you decide to convert that one dollar to a Euro, then the output should be . 90.

This chart provides the codes to be used as input (JPY, EURO, USD) and the conversion factors. Note that Step 2 DOES NOT HAVE TO USE OOP. Keep it simple.

Note that you CANNOT test for equality between strings using ==. String color = "red";

THIS WILL NOT WORK: if (color == "red")

YOU MUST USE if (color.equals("red") Using the JOptionPane GUI, do the following.

Prompt the user for the currency code type.

Prompt the user for the amount of that currency.

Prompt the user for the currency code that the entered amount must be converted to.

Using the table above, the following formula was used to convert USD to EURO.

100.00 USD * .9 = 90.00 EURO

Display the results in a JOptionPane message box.

Recommended publications