First Program: Fall 2024

22 Aug 2024 - 17:13 | Version 1 |

Learning Objective(s)

  1. Get the environment up and working
  2. Enter your first program

Overview of the Program

This lab has two parts. Part one is to create a virtual machine in which you will store all work for this class. Part two is to edit a program to change its functionality a little.

Specifics

Part One

For this part it is ESSENTIAL that you ONLY use your betheluniversity.edu account! Any other account (including a google account) will cause major problems!
  1. Follow the instructions to create your virtual machine.
    1. Step one is to redeem the coupon. Be EXTREMELY careful about how you are logged in with your browser!
    2. Create a project in the csc121fa2024 folder using your name. For me, I might choose cathybareiss
    3. invoke the shell
    4. enter: gcloud config set project {your project id (not name)}. For me, that would be cathybareiss
       gcloud config set project cathybareiss
    5. enter the following (the {YOUR INSTANCE NAME} should be the name you want for the machine such as: BareissProg1
       gcloud compute instances create {your own name for the machine} --image-project fall2024-433217 --image csc121f2024vm --zone us-central1-c --machine-type e2-medium
      my example would be:
       gcloud compute instances create bareissdemo --image-project fall2024-433217 --image csc121f2024vm --zone us-central1-c --machine-type e2-medium

      You might want to choose a different zone (esp. if you are having problems.)
  2. Remote into it from any machine using remote access. If you are on a Mac, you might need to download an app to allow the Mac to remote into a virtual Windows machine
  3. Launch JGrasp

Part Two

  1. In the CSC121 folder, you will find a program entitled SimpleCalculator.java. Load a copy of it into JGrasp
  2. Change the name of the class to InterestRate and resave it as InterestRate.java
  3. Change the code so that instead of getting two numbers (number1 and number2) it gets a price and an interest rate. Hint if needed. Try first without the hint
  4. Change the code so that it computes the interest. Hint if needed. Try first without the hint
  5. Change the code so that it computes the total cost. This is very similar to the previous step. Try it without looking at the hint. If you got the previous step, you should be able to get this one. Hint if needed. Try first without the hint
  6. Change the code so that it outputs both the interest and the total cost. Hint if needed. Try first without the hint
  7. Add your name to banner comment as the modifier of the code
  8. Save it
  9. Test it and make sure it works

Sample dialogue

Below is a sample dialogue. Your output can vary somewhat as long as the required data is nicely displayed
What is the original price?
100
What is the interest rate (10% is 0.1)?
0.15
You will pay 15.0 interest on the item
The total cost will be 115.0

You can also run a solution for this program if you want. See classroom instructions for more details.

Submission

  1. Once it works
    1. create a document that contains
      1. your name,
      2. what data you used to test it with
      3. what results you got for each data
      4. three different ways you could use the program
      5. a flowchart of the new program (editing the one for the sample program is fine)
      6. Answers to the following questions:
        1. Did you type in the code or just copy it it in and change it? Why?
        2. Did you use the virtual machine? If not, why not?
        3. What did you learn doing the lab?
        4. In terms of hours and/or minutes, how long did it take you to do the lab
    2. create a pdf document from that document
    3. create an empty zip folder
    4. place only InterestRate.java and your pdf document into it
    5. submit the zip folder on canvas

Optional improvements

Optional improvements should ONLY be worked on once the program is completing working. In addition, the work is to be done on your own with little if any help for lab assistants or the instructor. The advanced version should be called InterestRateAdv and you should place both .java codes in your zip folder.
  1. Make it so it always displays 2 (and only 2) numbers after the decimal point
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
This website is using cookies. More info. That's Fine