Description
Grade required: A
No plagerism
follow instructions throughly
consist of 2 parts first one will be mentioned as Lab 1 and second one as Lab 2
lab 1
1)
6 POINTS
CSIS 112 – Intro to Programming/Java
Assignment #1b – 20 pts
IMPORTANT NOTES:
¨ This is another easy homework, but this time you are doing easy programs that will be submitted via hypergrade.
¨ For this assignment you are going to be writing THREE short java programs. This means you will have THREE .java files; I do NOT want only one program or one .java file. The point is to practice making small java programs – THREE of them.
¨ DO NOT FORGET SIMPLE PSEUDOCODE for EACH program
o Put your pseudocode in comments at the top of your code
o Remember the simple pseudocode for our hello program: Display the text Hello World! on the screen
¨ Do not forget to put your name, the homework #, and the date in comments at the top of each program. If you work with someone else in doing the pseudocode, put their name down also.
¨ Once you have completed the three you will submit via hypergrade THREE things: THREE .java files – one for each program.
¨ IMPORTANT: Submit THREE .java files, one per question, do NOT one large file
For all Programs from here on out:
To get in the habit of writing pseudo-code write the simple pseudocode for these programs. Remember pseudocode is NOT repeating the instructions. When you are programming you may use as simple or as detailed of pseudocode as you determine is necessary for the program. PSEUDOCODE IS REQUIRED FOR ALL PROGRAMS.
This will be the standard format for turning in all homework assignments.
Homework #1b – Small Programs (THESE ARE JAVA PROGRAMS, PUT SIMPLE PSEUDOCODE AT THE TOP IN COMMENTS – see my pseudocode for Hello World)
For each program write the Java source code and compile and execute it in JGrasp. When you execute your programs make sure and test themto see that the output of the program is what you expect it to be (so make sure each program displays exactly what the problem specifies in the correct format).
Make sure your output for each program looks EXACTLY as shown. That means if there are quotes there you need to make the program display the quotes, if there is a space, you need to make the program display a space etc.
1. Hollow Rectangle Pattern: Write a program that displays the following pattern (6 pts):
&&&&&& &. & &. & &. & &. & &&&&&&
TEST CASE 1
&&&&&&n
& &n
& &n
& &n
& &n
&&&&&&n
Copyright 2022 HyperGrade, LLC · All Right Reserved
2)
6 POINTS
2. Diamond Pattern: Write a program that displays the following pattern (6 pts):
*
***
*****
*******
*****
***
*
TEST CASE 1
*n
***n
*****n
*******n
*****n
***n
*n
3)
8 POINTS
3. Write a program that displays the following information about 3 famous quotes on the screen (8 pts). The information should be displayed in the format shown. (Note that font size is not important just the format with which the information is displayed on the screen – use the escape sequences including tabs, backslash, and double quotes)
Note: will have to play with it a bit. Just use tabs to line up the Profession column and spaces to line up the “Famous Quote” column (tabs can be a bit of a pain). And you will lose points for just spacing and not using tabs for not lining up the Profession column.
Famous Person Profession Famous Quote ————- ————- ———–
William Shakespeare PlaywrightPoet “Listen to many, speak to a few.” Abraham Lincoln President “A house divided against itself cannot stand.” Rene Descartes Mathematician “Everything is self-evident.”
TEST CASE 1
Famous Person tProfession tFamous Quoten
————- t————- t———–n
William ShakespearetPlaywrightPoett”Listen to many, speak to a few.”n
Abraham Lincoln tPresident t”A house divided against itself cannot stand.”n
Rene Descartes tMathematician t”Everything is self-evident.”n
Copyright 2022 HyperGrade, LLC · All Right Reserved
lab 2
1)
6 POINTS
CSIS 112 – Intro to Programming/Java
30 pts
Lab #2
For all Programs:
To get in the habit of writing pseudo-code write the simple pseudo-code for these programs. Pseudo-code is not required for #1 – 3. (NOTE: #2 and #3 ARE pseudocode that you implement in Java and you can use that for examples in the pseudocode you write for #4-5)
Submit via hypergrade your source code and pseudo code by the due date.
Problem #1 (#1 ONLY) of this homework is NOT REQUIRED TO BE a program. However you may do Part 1 as a program if you would like to. If you don’t do Part 1 as a program, you should type up Part 1 of your assignment as a Word document or text file and submit it by the due date with the other .java files.
Lab #2 – Based on Chapter 2 Lecture (NO USER INPUT REQUIRED FOR THESE PROGRAMS)
1. (6 pts) Assuming that: amount = 1, m = 50, n=10, and p=5 (ALL INT DATA TYPES), evaluate the following expressions as the Java compiler would – this is NOT math class (so amount, m, n and p are variables). All of the variables (amount, m, n, and p) are of type integer. The results of the expressions therefore are also of type integer.
IMPORTANT: DO NOT ADD ANY OF YOUR OWN PARENTHESIS TO THE EXPRESSIONS THAT CHANGE THE RESULT OF THE MATH OPERATIONS. YOU CAN ONLY ADD PARENTHESIS TO THE “OUTSIDE” OF THE EXPRESSION. Example: 2+2 can be (2+2)
Do it by hand first then test your answers by writing a Java Program. The program should contain 5 integer variables: amount, m, n, p and result (a variable to store the result of each computation in so you can print them to the screen). With your program, be sure not to add any parenthesis and make sure you understand why Java is giving you each answer.)
a) n / p + 3
b) m / p + n – 10 * amount
c) m – 3 * n + 4 * amount
d) amount / 5
e) 18 / p
f) 18 % p
g) -p * n
h) -m / 20
i) -m % 20
j) (m + n) / (p + amount)
k) m + n / p + amount
TEST CASE 1
5n
10n
24n
0n
3n
3n
-50n
-2n
-10n
10n
53n
2)
6 POINTS
2. (6 pts) Convert the following pseudocode into a Java program (so I gave you the pseudocode for this one). Assume integer.
create speed, time
speed = 20
time = 10
distance = speed * time
Display distance
TEST CASE 1
200n
3)
6 POINTS
3. (6 pts) Convert the following pseudocode into a Java program (so I gave you the pseudocode for this one). Assume double.
create force, area, pressure
force = 172.5
area = 27.5
pressure = force / area
Display pressure
TEST CASE 1
6.2727272727272725n
4)
6 POINTS
4. (6 pts) Write a Java program that stores the number 105.62 in a variable named firstnum, the number 89.352 in a variable secondnum, and the number 98.67 in a variable thirdnum. (Be sure to declare the variables of a type that will not result in a loss of data).
Have your program calculate the total of the three numbers and their average. The total should be stored in a variable named total and the average in a variable named average. (Use the statement average = total / 3.0; to calculate the average). Display the total and average on the screen. Don’t forget pseudocode for this one.
TEST CASE 1
293.642n
97.88066666666667n
5)
6 POINTS
5. (6 pts) The East Coast Division of a company generates 62% of the company’s total sales. Based on that percentage, write a program that will predict how much the East Cost division will generate in sales if the company has $500,000 in sales this year. (Hint: use the value .62 to represent 62%). Print the results of the program to the screen (i.e. something like “For total sales of x, East Coast Division generated y” – with x and y being values). Don’t forget the pseudocode for this one.
(IMPORTANT NOTE: None of these programs require you to obtain input from the user. The purpose of these programs is to practice programming by declaring variables of the proper data types and performing arithmetic operations)
TEST CASE 1
For total sales of 500000.0 East Coast Division generated 310000.0n