import java.util.Scanner;
public class creditScore
{
public static void main(String[]args)
{
// declare and initialize variables
int creditScore;
double loanAmount,interestRate,interestAmount;
final double I_a = 5.56,I_b = 6.38,I_c = 7.12,I_d = 9.34,I_e = 12.45,I_f = 0;
String instructions = "This program calculates annual interest\n"+"based on a credit score.\n\n";
String output;
Scanner input = new Scanner(System.in);// for receiving input from keyboard
// get input from user
System.out.println(instructions );
System.out.println("Enter the loan amount: $");
loanAmount = input.nextDouble();
System.out.println("Enter the credit score: ");
creditScore = input.nextint();
System.out.println();// print blank line
//process data
if(creditScore>=720&&creditScore<=850)
interestRate = I_a;
else if(creditScore>=690&&creditScore<=719)
interestRate = I_b;
else if(creditScore>=660&&creditScore<=689)
interestRate = I_c;
else if(creditScore>=625&&creditScore<=689)
interestRate = I_d;
else if(creditScore>=590&&creditScore<=624)
interestRate = I_e;
else if(creditScore<590)
interestRate = I_f;
interestAmount = loanAmount*interestRate;
// output
output = "The loan amount is $" +loanAmount + "\n"
+ "The credit score is" + creditScore + "\n"
+ "The interest rate is" + interestRate + "\n"
+ "The interest is $" + interestAmount + "\n"
+ "End of program\n\n";
// display output
System.out.println(output);
}//end main
}//end class
output-
creditScore.java:28: error: cannot find symbol
creditScore = input.nextint();
^
symbol: method nextint()
location: variable input of type Scanner
1 error
please fix the error and update it
Program:
import java.io.*;
import java.util.Scanner;
public class CreditScore
{
public static void main(String[]args)throws IOException
{
// declare and initialize variables
int creditScore;
double loanAmount,interestRate=0.0,interestAmount;
// Here we are initializing interestRate as
0.0
final double I_a = 5.56,I_b = 6.38,I_c = 7.12,I_d = 9.34,I_e =
12.45,I_f = 0;
String instructions = "This program calculates annual
interest\n"+"based on a credit score.\n\n";
String output;
Scanner input = new Scanner(System.in);// for receiving input from
keyboard
// get input from user
System.out.println(instructions );
System.out.println("Enter the loan amount: $");
loanAmount = input.nextDouble();
System.out.println("Enter the credit score: ");
creditScore = input.nextInt(); // Here in nextInt I mst be
capital
System.out.println();// print blank line
//process data
if(creditScore>=720&&creditScore<=850)
interestRate = I_a;
else if(creditScore>=690&&creditScore<=719)
interestRate = I_b;
else if(creditScore>=660&&creditScore<=689)
interestRate = I_c;
else if(creditScore>=625&&creditScore<=689)
interestRate = I_d;
else if(creditScore>=590&&creditScore<=624)
interestRate = I_e;
else if(creditScore<590)
interestRate = I_f;
interestAmount = loanAmount*interestRate;
// output
output = "The loan amount is $" +loanAmount + "\n"
+ "The credit score is" + creditScore + "\n"
+ "The interest rate is" + interestRate + "\n"
+ "The interest is $" + interestAmount + "\n"
+ "End of program\n\n";
// display output
System.out.println(output);
}//end main
}//end class
Output:
import java.util.Scanner; public class creditScore { public static void main(String[]args) { // declare and initialize variables...
import java.util.Scanner; import java.util.ArrayList; public class P3A2_BRANDT_4005916 { public static void main(String[] args) { String name; String answer; int correct = 0; int incorrect = 0; Scanner phantom = new Scanner(System.in); System.out.println("Hello, What is your name?"); name = phantom.nextLine(); System.out.println("Welcome " + name + "!\n"); System.out.println("My name is Danielle Brandt. " +"This is a quiz program that...
Project 7-3 Guessing Game import java.util.Scanner; public class GuessNumberApp { public static void main(String[] args) { displayWelcomeMessage(); // create the Scanner object Scanner sc = new Scanner(System.in); String choice = "y"; while (choice.equalsIgnoreCase("y")) { // generate the random number and invite user to guess it int number = getRandomNumber(); displayPleaseGuessMessage(); // continue until the user guesses the number int guessNumber = 0; int counter = 1; while (guessNumber != number) { // get a valid int from user guessNumber...
Explain this java code, please. import java.util.Scanner; public class Program11 { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); final int maxSize = 128; String[] titles = new String[maxSize]; int[] lengths = new int[maxSize]; int numDVDs = 0; String op; op = menu(stdIn); System.out.println(); while (!op.equalsIgnoreCase("q")) { if (op.equalsIgnoreCase("a")) { if (numDVDs < maxSize) numDVDs = addDVD(titles, lengths, numDVDs, stdIn); } else if (op.equalsIgnoreCase("t")) searchByTitle(titles, lengths, numDVDs, stdIn); else if (op.equalsIgnoreCase("l")) searchByLength(titles, lengths, numDVDs, stdIn); System.out.println('\n');...
//LinkedList import java.util.Scanner; public class PoD { public static void main( String [] args ) { Scanner in = new Scanner( System.in ); LinkedList teamList = new LinkedList(); final int TEAM_SIZE = Integer.valueOf(in.nextLine()); for (int i=0; i<TEAM_SIZE; i++) { String newTeamMember = in.nextLine(); teamList.append(newTeamMember); } while (in.hasNext()) { String removeMember = in.nextLine(); teamList.remove(removeMember); } System.out.println("FINAL TEAM:"); System.out.println(teamList); in.close(); System.out.print("END OF OUTPUT"); } } =========================================================================================== //PoD import java.util.NoSuchElementException; /** * A listnked list is a sequence of nodes with...
import java.util.Scanner; public class MPGMain { public static void main(String[] args) { Scanner input = new Scanner(System.in); Mileage mileage = new Mileage(); System.out.println("Enter your miles: "); mileage.setMiles(input.nextDouble()); System.out.println("Enter your gallons: "); mileage.setGallons(input.nextDouble()); System.out.printf("MPG : %.2f",mileage.getMPG()); } } public class Mileage { private double miles; private double gallons; public double getMiles()...
public static void main(String[] args) { System.out.println("Welcome to the Future Value Calculator\n"); Scanner sc = new Scanner(System.in); String choice = "y"; while (choice.equalsIgnoreCase("y")) { // get the input from the user System.out.println("DATA ENTRY"); double monthlyInvestment = getDoubleWithinRange(sc, "Enter monthly investment: ", 0, 1000); double interestRate = getDoubleWithinRange(sc, "Enter yearly interest rate: ", 0, 30); int years = getIntWithinRange(sc, "Enter number of years: ", 0, 100); System.out.println(); ...
import java.util.Scanner; public class TriangleMaker { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Welcome to the Triangle Maker! Enter the size of the triangle."); Scanner keyboard = new Scanner(System.in); int size = keyboard.nextInt(); for (int i = 1; i <= size; i++) { for (int j = 0; j < i; j++) { System.out.print("*"); } System.out.println(); } for (int...
import java.util.Scanner; public class TempConvert { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); //ask the user for a temperature System.out.println("Enter a temperature:"); double temp = scnr.nextDouble(); //ask the user for the scale of the temperature System.out.println("Is that Fahrenheit (F) or Celsius (C)?"); char choice = scnr.next().charAt(0); if(choice == 'F') { //convert to Celsius if given temperature was Fahrenheit System.out.println(temp + " degrees Fahrenheit is " + ((5.0/9) * (temp-32)) + " degrees Celsius"); } else {...
import java.util.Scanner; public class StudentClient { public static void main(String[] args) { Student s1 = new Student(); Student s2 = new Student("Smith", "123-45-6789", 3.2); Student s3 = new Student("Jones", "987-65-4321", 3.7); System.out.println("The name of student #1 is "); System.out.println("The social security number of student #1 is " + s1.toString()); System.out.println("Student #2 is " + s2); System.out.println("the name of student #3 is " + s3.getName()); System.out.println("The social security number...
import java.util.Scanner; public class SCAN { public static void main(String[ ] args) { int x, y, z; double average; Scanner scan = new Scanner(System.in); System.out.println("Enter an integer value"); x = scan.nextInt( ); System.out.println("Enter another integer value"); y = scan.nextInt( ); System.out.println("Enter a third integer value"); z = scan.nextInt( ); average = (x + y + z) / 3; System.out.println("The result of my calculation is " + average); } } What is output if x = 0, y = 1 and...