Question

You will write Java programs in Eclipse to solve these word problems Read these instructions on how to name and submit the Java files. Please make sure your program compiles before you submit it. Make sure you name your Java file and class the same (otherwise it will not compile). For example, the class names are case-sensitive 1. will be in a file called CompareNames.java; remember, the Do not create a package. You can tell if your file is in a package if there is a package statement near the top of it 2. 3. Make sure you use the checkbox to create the Javadoc comments, and you put your name in the file as the @author. LAB 3 Create a Project called LoanDecisign with a class called LaanDecisian Write a Java program to approve or reject a loan based on the borrowers credit score. Ask for the following values (use double variables) Credit Score (must be between 300 and 850) Loan Amount (must be between 500 and 20000) You should start by copying your code from CreditScore and modify it as follows a. Define an enum (CreditRiskEnum) for the credit risk (EXCELLENT, VERYGOOD, GOOD, b. Assign the correct enum value to a variable creditRisk with multi-way branching (if c. Use a switch statement on the creditRisk variable, then use an if statement in each FAIR, POOR, INVALID). Put it inside your class, above the main method - else if) case to approve the loan if it is less than or equal to the credit limit creditRisk INVALID POOR 500 FAIR 1000 GOOD 2,000 VERYGOOD 5,000 EXCELLENT 10,000 If either of the input values is out of range, output an error message CreditScore2 by Ray Henry Enter the Credit Score: 644 Enter the Loan Amount 1001 The loan application is denied

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class LoanDecision {

public enum CreditRiskEnum { EXCELLENT, VERYGOOD, GOOD,FAIR,POOR,INVALID }  

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

System.out.println("CreditScore2 by Ray Henry");

//taking credit score from the user

System.out.print("Enter the Credit Score: ");

int creditScore=sc.nextInt();

boolean valid=true;

if(creditScore<300 || creditScore>850) {System.out.println("The credit score is invalid.");valid=false;}

//taking loan amount form the user

System.out.print("Enter the Loan Amount:");

int loanAmount=sc.nextInt();

//using the condition checking the validation is working or not

if(loanAmount<500 || loanAmount>20000) {System.out.println("The loan amount is invalid.");valid=false;}

//if it valid when satisfied loan amount 500,100,2000,5000,10000

if(valid && (loanAmount==500 || loanAmount==1000 ||loanAmount==2000 || loanAmount==5000 ||loanAmount==10000)){

System.out.println("The loan application is approved");

}

else

{

System.out.println("The loan application is denied");

}

}

}

Creditscore2 by Ray Henry Enter the Credit Score: 0 The credit score is invalid. Enter the Loan Amount: 400 The loan The loan application is denied amount is invalid

Add a comment
Know the answer?
Add Answer to:
You will write Java programs in Eclipse to solve these word problems Read these instructions on...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a simple Java program with the following naming structure: Open Eclipse Create a workspace called...

    Write a simple Java program with the following naming structure: Open Eclipse Create a workspace called hw1 Create a project called hw1 (make sure you select the “Use project folder as root for sources and class files”) Create a class called Hw1 in the hw1 package (make sure you check the box that auto creates the main method). Add a comment to the main that includes your name Write code that demonstrates the use of each of the following basic...

  • 4.3Learning Objective: To read and write text files. Instructions: This is complete program with one Java...

    4.3Learning Objective: To read and write text files. Instructions: This is complete program with one Java source code file named H01_43.java (your main class is named H01_43). Problem: Write a program that prompts the user for the name of a Java source code file (you may assume the file contains Java source code and has a .java filename extension; we will not test your program on non-Java source code files). The program shall read the source code file and output...

  • Course, Schedule, and ScheduleTester (100%) Write a JAVA program that meets the following requirements: Course Class Cr...

    Course, Schedule, and ScheduleTester (100%) Write a JAVA program that meets the following requirements: Course Class Create a class called Course. It will not have a main method; it is a business class. Put in your documentation comments at the top. Be sure to include your name. Course must have the following instance variables named as shown in the table: Variable name Description crn A unique number given each semester to a section (stands for Course Registration Number) subject A...

  • CIST 1305 Unit 06 Drop Box Assignment General Instructions You will create a word processing document...

    CIST 1305 Unit 06 Drop Box Assignment General Instructions You will create a word processing document and save it in "PDF" format. If you turn your document in using the wrong format, you will get no credit for it. ONLY ONE FILE may be turned in for the assignment. If you make a mistake and need to turn in your work again, you may do so. I will only grade the latest file you turn in. The older ones will...

  • For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java...

    For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java program that will input a file of sentences and output a report showing the tokens and shingles (defined below) for each sentence. Templates are provided below for implementing the program as two separate files: a test driver class containing the main() method, and a sentence utilities class that computes the tokens and shingles, and reports their values. The test driver template already implements accepting...

  • Today you are to write a Java program that will prompt for and read 2 words...

    Today you are to write a Java program that will prompt for and read 2 words of equal length entered by the user, and create a new word which contains the last letter of the 1st word, the last letter of the 2nd word, followed by the second to last character of the 1st word, followed by the second to last character of the 2nd word and so on. Be sure to use the same format and wording as in...

  • Write a Java program in Eclipse that reads from a file, does some clean up, and...

    Write a Java program in Eclipse that reads from a file, does some clean up, and then writes the “cleaned” data to an output file. Create a class called FoodItem. This class should have the following: A field for the item’s description. A field for the item’s price. A field for the item’s expiration date. A constructor to initialize the item’s fields to specified values. Getters (Accessors) for each field. This class should implement the Comparable interface so that food...

  • Write code to create a Java class called "Student". The class should hold information about a...

    Write code to create a Java class called "Student". The class should hold information about a student: name, id and whether or not the student is currently registered. There should be a constructor that takes name, id and registration status. Add getters and setters for the three properties. Make sure that you use appropriate visibility modifiers (public vs. private).

  • Please Implement this code using Java Eclipse. CIS 1068 Assignment 8 Warm Up with Objects Due:...

    Please Implement this code using Java Eclipse. CIS 1068 Assignment 8 Warm Up with Objects Due: Wednesday, March 25 70 points (+ up to 15 extra credit) The purpose of this assignment is to give you practice implementing your own classes. It also provides extra practice with arrays. Task Implement a class Task, which is used to represent a job that should be done. It should contain the following private fields: .name text description of what job should be done...

  • write programs with detailed instructions on how to execute. code is java What you need to...

    write programs with detailed instructions on how to execute. code is java What you need to turn in: You will need to include an electronic copy of your report (standalone) and source code (zipped) of your programs. All programming files (source code) must be put in a zipped folder named "labl-name," where "name" is your last name. Submit the zipped folder on the assignment page in Canvas; submit the report separately (not inside the zipped folder) as a Microsoft Word...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT