Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ITSS 3312 – Object-Oriented Programming Programming in Java Homework 1 IMPORTANT

ID: 3899168 • Letter: I

Question

ITSS 3312 – Object-Oriented Programming

Programming in Java

Homework 1

IMPORTANT NOTES:

In Eclipse IDE, Students should create a new project named: HOMEWORK_1

Problem 1:

Write a Java program that can calculate and print out the area of a square. The user enters data of the side and its measurement unit (“in” for inch, “ft” for feet, “cm” for centimeter, and “m” for meter) from the console. The program should check to be sure that the side is not negative and the measurement unit must be one among the listed-above units.

Important Notes:

Assumed that the user makes mistakes at most once for the side value and once for the measurement unit while entering the data, i.e. he/she enters the correct value the next time right after being warned.
In Eclipse IDE, inside the newly created project HOMEWORK_1, students should create a new program, i.e. a class, named: Program_1 under a new package named PROBLEM_1 for his/her work on this problem.
To submit, students copy all the code of the program into a Notepad file (and keep all the original Eclipse format) – NOT Microsoft Words, NOT Wordpad, name the file as “hw1_program1” (the file should have the suffix .txt),

Problem 2: can also use “if else” statements

Write a program that can convert an integer between 0 and 15 into hex number (including 0 and 15). The user enters an integer from the console and the program displays the corresponding hex number. If the user enters an integer out of range, the program displays a warning message about the invalid input.

Table. Conversion between Decimal and Hexadecimal

Decimal

Hexadecimal

0

0

1

1

2

2

3

3

4

4

5

5

6

6

7

7

8

8

9

9

10

A

11

B

12

C

13

D

14

E

15

F

Important Notes:

Assumed that the user makes mistakes at most once while entering the data, i.e. he/she enters the correct value the next time right after being warned.
In Eclipse IDE, inside the newly created project HOMEWORK_2, students should create a new program, i.e. a class, named: Program_2 under a new package named PROBLEM_2 for his/her work on this problem.
To submit, students copy all the code of the program into a Notepad file (and keep all the original Eclipse format) – NOT Microsoft Words, NOT Wordpad, name the file as “hw1_program2” (the file should have the suffix .txt)

Problem 3:

The consumer loan department of a bank asks a software analyst to write a Java program that can calculate the following amounts of a loan:

the monthly payment of a mortgage
the total payment (after all the monthly payments have been made)
the total interest (after all the monthly payments have been made)

After reading (from the console) necessary data – the loan amount, the loan period (in months), and the annual interest rate, the program processes the data and prints out (to the console) the following pieces of information in only one line:

The loan amount
The loan period (how many months)
The annual interest rate
^^^ put these 3 numbers in the same line (use d or f but no s) use when u do this (this info could be for the next step below, *check w/ professor*

Then the program prints out the monthly payment in the next line, and prints out the following pieces of information in another line:

The total payment
The total interest

The inputs must be verified to be sure that they are not negative. All the floating-point numbers of the outputs have 2 digits after the floating point.

Important Notes:

Annual interest rate is entered as percentage, i.e. 4.25 is entered for 4.25%

Formula to compute the monthly payment:

Formula to compute the monthly interest rate (in this formula, interest rate has it real value, not %. To get real value, divide the input of interest rate by 100)

Monthly interest rate = annual interest rate / 12

Formula to compute the total payment

Total payment = monthly payment * number of months

Formula to compute the total interest

Total interest = total payment - original loan amount

Important Notes:

In Eclipse IDE, inside the newly created project HOMEWORK_1, students should create a new program, i.e. a class, named: Program_3 under a new package named PROBLEM_3 for his/her work on this problem.
To submit, students copy all the code of the program into a Notepad file (and keep all the original Eclipse format) – NOT Microsoft Words, name the file as “hw1_Program3” (the file should have the suffix .txt)

Problem 4:

The consumer loan department of a bank asks a software analyst to write a Java program that can calculate

the monthly payment of a mortgage
the principal paid in each monthly payment
the interest paid in each monthly payment,

After reading (from the console) necessary data – the loan amount, the loan period (in months), and the annual interest rate, the program processes the data and then prints out (to the console) the following pieces of information as follows:

The loan amount in the 1st line
The loan period (how many months) in the 2nd line
The annual interest rate in the 3rd line

(Leave the next line blank)

Next, the program prints out the following text as shown:

Payment #:Monthly PaymentPrincipalInterestBalance

And finally the program prints out the following details of a monthly payment (one line for each payment)

Payment #
Monthly payment amount
Principal paid in the monthly payment
Interest paid in the monthly payment
Balance of the loan after the monthly payment

The inputs must be verified to be sure that they are not negative. All the floating-point numbers of the outputs have 2 digits after the floating point.

Sample of the outputs:

Loan amount: 10000.00

Number of months:        6

Annual interest rate:     2.00

Payment #        Monthly Payment         Principal          Interest            Balance

1                      1676.40                       1659.74           16.67               8340.26

2                      1676.40                       1662.50           13.90               6677.76

3                      1676.40                       1665.27           11.13               5012.49

4                      1676.40                       1668.05           8.35                 3344.44

5                      1676.40                       1670.83           5.57                 1673.61

6                      1676.40                       1673.61           2.79                    0.00

Important Notes:

Formula to compute the monthly payment:

Other formulas:

Monthly interest rate = annual interest rate / 12
Interest (in monthly payment) = monthly interest rate * current balance
principal (in monthly payment) = monthly payment - interest
balance (after monthly payment has been paid) = current balance - principal

Important Notes:

In Eclipse IDE, inside the newly created project HOMEWORK_1, students should create a new program, i.e. a class, named: Program_4 under a new package named PROBLEM_4 for his/her work on this problem.
To submit, students copy all the code of the program into a Notepad file (and keep all the original Eclipse format) – NOT Microsoft Words, name the file as “hw1_Program4” (the file should have the suffix .txt)

Explanation / Answer

As per Chegg policy, we are supposed to answer first complete question. Request you post other question separately , one in each post.
Given below is the code for the question 1. You need to create a package named Problem_1 in your project and the place the code in a file named Program_1.java

To indent code in eclipse , select code by pressing ctrl+a and then indent using ctrl+i
Please do rate the answer if it was helpful. Thank you

package Problem_1;

import java.util.Scanner;

public class Program_1 {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int side;
String units;

System.out.print("Enter the side length of the square: ");
side = keyboard.nextInt();

if(side < 1)
{
System.out.print("Invalid side length! Please enter a positive value for side length: ");
side = keyboard.nextInt();
}


System.out.print("Enter the units (in, ft, cm, m): ");
units = keyboard.next();

if(!(units.equals("in") || units.equals("ft") || units.equals("cm") || units.equals("m")))
{
System.out.print("Invalid units! Please enter one of in, ft, cm or m: ");
units = keyboard.next();
}

int area = side * side;

System.out.println("The total area of the square is " + area + " sq " + units);
}
}


output
====
Enter the side length of the square: -3
Invalid side length! Please enter a positive value for side length: 4
Enter the units (in, ft, cm, m): abc
Invalid units! Please enter one of in, ft, cm or m: cm
The total area of the square is 16 sq cm

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote