Question
Problem 1: As a programmer, you currently participate in developing a game. Today your task is developing a class to represent users. Thinking in the
Problem 1:
As a programmer, you currently participate in developing a game. Today your task is developing a class to represent users. Thinking in the way of Object Oriented Programming, you want to create a class called User. This class should have three attributes, which are username, nickname, and password. For each class, you should create its corresponding set() and get() methods. Also make sure to have a construction method in the class.
In another class named Program_1, you should first prompt the user to create a profile, which contains all the three attributes. Then you ask the user whether she wants to change the password. The user would answer Yes. Before changing password for the user, you ask for the original password and check whether it is correct. If it is correct, you then prompt the user to input the new password.
Important Notes:
- Assumed that the user always correctly enters the input.
- 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_1for his/her work on this problem.
Problem 2:
Write a Java program that can compute the interest on the next monthly mortgage payment. The program reads the balance and the annual percentage interest rate (e.g.: for an interest rate of 4.25%, the user should enter 4.25) from the console. The program should check to be sure that the inputs of balance and the interest rate are not negative. After the computation, the program displays the interest amount as a floating-point number with 2 digits after the floating point.
Formula: the interest on the next monthly mortgage payment can be computed using the following formula:
Interest = balance x (annualInterestRate / 1200)
Important Notes:
- Assumed that the user makes mistakes at most once forthe balance and once for the annual percentage interest rate 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_2 under a new package named PROBLEM_2for his/her work on this problem.
Problem 3:
Write a program that can compare the unit (per lb) cost of sugar sold in packages with different weights and prices. The program prompts the user to enter the weight and price of package 1, then does the same for package 2, and displays the results to indicate sugar in which package has a better price. It is assumed that the weight of all packages is measured in lb. The program should check to be sure that both the inputs of weight and price are both positive values.
Important Notes:
- Assumed that the user makes mistakes at most once for the weight and once for the price 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_3under a new package named PROBLEM_3for his/her work on this problem.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started