project1
- Due Sep 8, 2017 by 11am
- Points 30
- Available Sep 2, 2017 at 12am - Sep 8, 2017 at 11:59pm
Computer Science 111 Intro to Algorithms and Programming: Java
Programming Project #1 – Simple Programming Exercises (30 points)
This project assumes you have followed the NetBeans instructions and can create and run a simple Java program using NetBeans. If you have NOT done this, STOP, go back and practice the NetBeans instructions.
Create a folder on your memory stick or your laptop hard drive for ALL your java projects. Something like 'e:\javaprojects' or 'c:\javaprojects', your drive letter may be different. If you are using the lab computer hard drive, you MUST email the code to yourself when you are done.
MyInitials: Create a NetBeans project named 'Project1'.
Create a main class with the name 'MyInitials'. In the main method insert print statements to display your initials (2-3 letters) using an 8 X 8 pattern. For example, here is an 8 X 8 pattern of the letter 'J':
J J J J J J J J J J J J It will take eight (8) print line statements to complete the exercise.
DisplayResult: DO NOT create another project, we are going to add a new file to 'Project1'. From the NetBeans 'File' menu select 'New File'. On the dialog box under 'File Type' select 'Java Main Class' and hit 'Next'. Create a main class with the name ‘DisplayResult’, verify it is part of 'Project1' and press 'Finish'. In the main method insert print statements to display the result of following expression.
(9.5 x 4.5 – 2.5 x 3)/(45.5 -3.5)
Do not use any variables, just print statement to display your results.
Chapter 2 - Week 2
Just a reminder, add your work to the 'Project1' folder. If you are using a memory stick or laptop you can run NetBeans and from the 'File' menu select 'Open Project", locate and open your 'Project1'. If you are using the lab computer hard drive, you MUST create 'Project1' from scratch, then copy and paste your existing code from your email.
FeetMeters: From the NetBeans 'File' menu select 'New File'. On the dialog box under 'File Type' select 'Java Main Class' and hit 'Next'. Create a main class with the name 'FeetMeters', verify it is part of 'Project1' and press 'Finish'. In the main method create code which converts feet to meters, using the formula:
1 foot = .305 meters // this is NOT Java, you create the Java You need to create two variables (inside main), and print the result of the calculation. At first, just assign a simple value to the variable feet. If you can get that to work, try to input the value of feet from the keyboard.
CalculateTip: From the NetBeans 'File' menu select 'New File'. On the dialog box under 'File Type' select 'Java Main Class' and hit 'Next'. Create a main class with the name 'CalculateTip', verify it is part of 'Project1' and press 'Finish'. In the main method create code which calculates and prints a tip amount and a total using the formulas:
tip = subtotal * tiprate; total = subtotal + tip; You need to create four variables (inside main), and print the results of the calculations (tip and total). At first, just assign a simple value to the variables. If you can get that to work, try to input the values from the keyboard.
NumberOfYears: From the NetBeans 'File' menu select 'New File'. On the dialog box under 'File Type' select 'Java Main Class' and hit 'Next'. Create a main class with the name NumberOfYears, verify it is part of 'Project1' and press 'Finish'. Write a program that prompts the user to enter the days and displays the number of years and remaining days. For simplicity, assume a year has 365 days.
You need to create three variables (inside main) and print the result.
APowerofB : From the NetBeans 'File' menu select 'New File'. On the dialog box under 'File Type' select 'Java Main Class' and hit 'Next'. Create a main class with the name APowerofB, verify it is part of 'Project1' and press 'Finish'. Write a program that calculates exponential values and displays following table. Cast floating-point numbers into integers.
a b pow(a,b)
1 2 1
2 3 8
3 4 81
4 5 1024
5 6 15625