4 intro to java tasks using simple loops and if else statements

Task 1

File: HW4_VerifyCountBy.java

Write a program that will verify the answers of a kid learning counting by different amounts. For example if I count by 3 starting at 5 and ending at 21 I get: 5, 8, 11, 14, 17, 20 (each new number is the previous one +3). The next number would be 23 and that is not less or equal than 21.
The program should read three integers: start, end, countBy. After that, it should let the user enter the numbers (by hitting ENTER after each one) and it will verify if they are correct. See the sample runs below: You can assume that the user will always enter only positive numbers. E.g. You do not need to worry about what happens if the step is negative.
Hint: In a for loop you can initialize the loop variable (e.g. i) with any value you want.

----------  Sample run 1_x000D_
This program will be counting by a certain step._x000D_
Enter what you want the start, end and stop values to be._x000D_
start is:  3_x000D_
end is:  15_x000D_
step is:   2_x000D_
Enter the numbers (starting with 3):_x000D_
Enter your answer:  3_x000D_
Correct_x000D_
Enter your answer:  5_x000D_
Correct_x000D_
Enter your answer:  7_x000D_
Correct_x000D_
Enter your answer:  8_x000D_
Wrong. The correct answer was: 9_x000D_
Enter your answer:  11_x000D_
Correct_x000D_
Enter your answer:  13_x000D_
Correct_x000D_
Enter your answer:  15_x000D_
Correct _x000D_
Bye_x000D_
_x000D_
----------  Sample run 2_x000D_
This program will be counting by a certain step._x000D_
Enter what you want the start, end and stop values to be._x000D_
start is:  3_x000D_
end is:  12_x000D_
step is:  4_x000D_
Enter the numbers (starting with 3):_x000D_
Enter your answer:  3_x000D_
Correct_x000D_
Enter your answer:  7_x000D_
Correct_x000D_
Enter your answer:  11_x000D_
Correct_x000D_
Bye_x000D_
 _x000D_
----------  Sample run 3_x000D_
This program will be counting by a certain step._x000D_
Enter what you want the start, end and stop values to be._x000D_
start is:  3_x000D_
end is:  12_x000D_
step is:  4_x000D_
Enter the numbers (starting with 3):_x000D_
Enter your answer:  3_x000D_
Correct_x000D_
Enter your answer:  6_x000D_
Wrong. The correct answer was: 7_x000D_
Enter your answer:  11_x000D_
Correct_x000D_
Bye_x000D_
_x000D_
------------  Sample run 44_x000D_
This program will be counting by a certain step._x000D_
Enter what you want the start, end and stop values to be._x000D_
start is:  12_x000D_
end is:  100_x000D_
step is:  21_x000D_
Enter the numbers (starting with 12):_x000D_
Enter your answer:  12_x000D_
Correct_x000D_
Enter your answer:  33_x000D_
Correct_x000D_
Enter your answer:  54_x000D_
Correct_x000D_
Enter your answer:  75_x000D_
Correct_x000D_
Enter your answer:  96_x000D_
Correct_x000D_
Bye_x000D_

Task 2

File: HW4_Passsword.java

Write a program that repeatedly asks the user to enter their password until they enter the correct one. However, after 5 failed attempts, the program “locks out” the user. We will show that with an error message.
Assume the password is CSE1310 (case sensitive).
Note that there is a special case that is not shown below. To identify it, think of all possible scenarios of input for this program.

----------- Sample run 1:_x000D_
Enter your password: Alex_x000D_
Wrong_x000D_
Enter your password: cat1546_x000D_
Wrong_x000D_
Enter your password: cse1310_x000D_
Wrong_x000D_
Enter your password: CSE1310_x000D_
Correct! You're in!_x000D_
Bye _x000D_
_x000D_
----------- Sample run 2:_x000D_
Enter your password: CSE1310_x000D_
Correct! You're in!_x000D_
Bye_x000D_
 _x000D_
----------- Sample run 3:_x000D_
Enter your password: Alex_x000D_
Wrong_x000D_
Enter your password: cat1546_x000D_
Wrong_x000D_
Enter your password: cse1310_x000D_
Wrong_x000D_
Enter your password: CSE_x000D_
Wrong_x000D_
Enter your password: 1310_x000D_
Wrong_x000D_
You are locked out!_x000D_
Bye_x000D_
 

Task 3

File: HW4_CountVowelsOnce.java

Count vowels with or without repetitions and case insensitive. For example heat has 2 distinct vowels (e and a) and 2 total vowels, but heel has one distinct vowel (e), but 2 total vowels.
You must print the ” as shown in the sample output.
Vowels: A, E, O, U, I, Y .

----  Sample run:_x000D_
Enter a phrase. I will count the vowels._x000D_
You are such a show-off!_x000D_
There are 5 distinct vowels in "You are such a show-off!"._x000D_
There are 9 total vowels in "You are such a show-off!"._x000D_
Bye_x000D_
_x000D_
----  Sample run:_x000D_
Enter a phrase. I will count the vowels._x000D_
cnt ths f cn_x000D_
There are 0 distinct vowels in "cnt ths f cn"._x000D_
There are 0 total vowels in "cnt ths f cn"._x000D_
Bye_x000D_
_x000D_
----  Sample run:_x000D_
Enter a phrase. I will count the vowels._x000D_
I give up..._x000D_
There are 3 distinct vowels in "I give up..."._x000D_
There are 4 total vowels in "I give up..."._x000D_
Bye_x000D_

Task 4 – 2-3 step processing, non-trivial data manipulation, formatted printing

File: HW4_Bank.java

Write a program that simulates bank transactions for an account. When the program starts, the user is prompted to enter the amount of money in their account.

Next the user is repeatedly prompted for transactions. He/she enters a real number for each transaction:

  1. positive numbers mean money added to the bank.
  2. negative numbers mean money removed from the bank.
  3. 0 means the user has no more transactions. The loop will stop.

Finally the program should display a message that compares the current balance with the original one (before the transactions).

See sample runs below.

Match the output, especially the formatted printing of the transaction and balance.

--- Sample run 1:_x000D_
This program simulates transactions in a bank account._x000D_
Enter your current balance (money in your account): 1076.1234_x000D_
Enter transaction: 15_x000D_
|transaction|    balance|_x000D_
|      15.00|    1091.12|_x000D_
Enter transaction: -20_x000D_
|transaction|   balance|_x000D_
|     -20.00|    1071.12|_x000D_
Enter transaction: 100_x000D_
|transaction|    balance|_x000D_
|     100.00|    1171.12|_x000D_
Enter transaction: 80_x000D_
|transaction|    balance|_x000D_
|      80.00|    1251.12|_x000D_
Enter transaction: -2000_x000D_
|transaction|    balance|_x000D_
|   -2000.00|    -748.88|_x000D_
Enter transaction: 50_x000D_
|transaction|    balance|_x000D_
|      50.00|    -698.88|_x000D_
Enter transaction: 0_x000D_
You lost money._x000D_
Bye_x000D_
_x000D_
--- Sample run 2:_x000D_
This program simulates transactions in a bank account._x000D_
Enter your current balance (money in your account): 89.56789_x000D_
Enter transaction: 10_x000D_
|transaction|    balance|_x000D_
|      10.00|      99.57|_x000D_
Enter transaction: -5_x000D_
|transaction|    balance|_x000D_
|      -5.00|      94.57|_x000D_
Enter transaction: 20_x000D_
|transaction|    balance|_x000D_
|      20.00|     114.57|_x000D_
Enter transaction: 60_x000D_
|transaction|    balance|_x000D_
|      60.00|     174.57|_x000D_
Enter transaction: 0_x000D_
You made money or have the same as when you started._x000D_
Bye_x000D_
_x000D_
--- Sample run 3:_x000D_
This program simulates transactions in a bank account._x000D_
Enter your current balance (money in your account): 0_x000D_
Enter transaction: 15.789_x000D_
|transaction|    balance|_x000D_
|      15.79|      15.79|_x000D_
Enter transaction: -15.789_x000D_
|transaction|    balance|_x000D_
|     -15.79|       0.00|_x000D_
Enter transaction: 0_x000D_
You made money or have the same as when you started._x000D_
Bye_x000D_
--- Sample run 4:_x000D_
This program simulates transactions in a bank account._x000D_
Enter your current balance (money in your account): -100_x000D_
Enter transaction: 0_x000D_
You made money or have the same as when you started._x000D_
Bye

All programs must match the sample runs exactly.

 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.