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

Assignment Overview This assignment will give you practice with interactive prog

ID: 3788983 • Letter: A

Question

Assignment Overview This assignment will give you practice with interactive programs and if/else statements.

Part 1: User name Generator Write a program that prompts for and reads the user’s first and last name (separately). Then print a string composed of the first letter of the user’s first name, followed by the first five characters of the user’s last name, followed by a random number in the range 10 to 99. Assume that the last name is at least five letters long. Similar algorithms are sometimes used to generate usernames for new computer accounts. CLASS NAME. Your program class should be called UserNameGenerator.java. Sample run: Enter your first name: William Enter your last name: Henry Username: WHenry88 Part 2: Bank Charges [20 points] A bank charges a base fee of $10 per month, plus the following check fees for a commercial checking account:

$.10 each for less than 20 checks

$.08 each for 20–39 checks

$.06 each for 40–59 checks

$.04 each for 60 or more checks

Write a program that asks for the number of checks written for the month. The program should then calculate and display the bank’s service fees for the month. CLASS NAME. Your program class should be called BankCharges.java. Sample run 1: Enter the number of checks written this month: 30 The total fees are $12.40 Sample run 2: Enter the number of checks written this month: 30 The total fees are $12.40

Sample run 3: Enter the number of checks written this month: 45 The total fees are $12.70

Sample run 4: Enter the number of checks written this month: 70 The total fees are $12.80 ______________________________________________________________

Rules:

For this assignment you are limited to the language features in Chapters 1 through 4; you are not allowed. (The text is Intro to Java 10th edition Y. Liang) to use more advanced features to solve the problem. Please do not use Java features that are not covered in lecture or the textbook.

Use class constants as appropriate to represent important fixed data values in your program.

You are required to properly indent your code and will lose points if you make significant indentation mistakes. You should also use whitespace properly to make your program more readable, such as between operators and their operands, between parameters, and blank lines between groups of statements or methods.

Java's naming standards about the format of ClassNames, VariableNames, and CONSTANT_NAMES.

Include a comment at the beginning of your program with basic information.

You should use at least one switch statement or at least one multi-way if-statement (using "else if").

Much of your code will involve conditional execution with if and if/else statements. Part of your grade will come from using these statements appropriately.

Notice that all real numbers output by the program are printed with no more than 2 digits after the decimal point. To achieve this, you may use the System.out.printf method as follows. // print exam score, rounded to 2 decimal places System.out.printf("%.2f", ExamScore);

Explanation / Answer

Hi,

Please see below the Java classes. Please comment for any queries/ feedbacks.

Thanks,

Anita

UserNameGenerator.java

import java.util.Random;
import java.util.Scanner;


public class UserNameGenerator {
   //Minimum and Maximum Constants for for Random number generation
   public static final int MIN = 10;
   public static final int MAX = 99;

   public static void main(String [] args){
       String FirstName;
       String LastName;
       String UserName;

       Scanner scan = new Scanner(System.in);
       System.out.println("Enter your first name: ");
       FirstName = scan.nextLine();
       System.out.println("Enter your last name: ");
       LastName = scan.nextLine();

       UserName = generateUserName(FirstName,LastName);

       System.out.println("Username: "+UserName);

   }

   public static String generateUserName(String firstName, String lastName){
       int random = 0;
       Random r = new Random();
       String userName = "";
       //1.First letter of First Name
       userName = firstName.substring(0, 1);

       //Getting first 5 characters of lastName
       userName = userName + lastName.substring(0, 5);

       //Fenerating Random number between 10 an 99
       random = r.nextInt(MAX-MIN) + MIN;
       userName = userName + random;

       return userName;

   }

}

Sample output:

Enter your first name:
William
Enter your last name:
Henry
Username: WHenry95

BankCharges.java

import java.util.Scanner;


public class BankCharges {
   //Fee Constants
   public static final double BASE_FEE = 10;
   public static final double LESS_THAN_TWENTY_FEE = .10;
   public static final double TWENTY_THIRTYNINE_FEE = .08;
   public static final double FOURTY_FIFTYNINE_FEE = .06;
   public static final double SIXTY_OR_MORE_FEE = .04;

   public static void main(String[] args){
       String NoOfChecksStr = "";
       int NoOfChecks = 0;
       double fee = 0;
       Scanner scan = new Scanner(System.in);
       System.out.println("Enter the number of checks written this month: ");
       NoOfChecksStr = scan.nextLine();

       NoOfChecks = Integer.valueOf(NoOfChecksStr);


       //Calculating Fee based on the No of checks
       if(NoOfChecks < 20){
           fee = BASE_FEE + (NoOfChecks * LESS_THAN_TWENTY_FEE);
       }
       else if(NoOfChecks>=20 || NoOfChecks<40 ){
           fee = BASE_FEE + (NoOfChecks * TWENTY_THIRTYNINE_FEE);
       }
       else if(NoOfChecks>=40 || NoOfChecks<60 ){
           fee = BASE_FEE + (NoOfChecks * FOURTY_FIFTYNINE_FEE);
       }
       else if(NoOfChecks>=60 ){
           fee = BASE_FEE + ( NoOfChecks * SIXTY_OR_MORE_FEE);
       }

       System.out.printf("The total fees are %.2f", fee);

   }

}

Sample outputs:


Enter the number of checks written this month:
30
The total fees are 12.40

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