Program That Prompts The User To Enter Loan Amount And Years
Oct 21, 2014
so I had to make a program that prompts the user to enter a loan amount and the years for the loan and I have the conversions and everything my only issue is that when the chart pops up it just looks like a bunch of numbers and its missing the column headers
for example
Interest Rate Monthly Payment Total Payment
import java.util.Scanner;
public class InterestRate {
public static void main(String[] args) {
double monthlypayment = 0;
double totalpayment = 0;
Scanner input = new Scanner(System.in);
System.out.println("Enter Loan Amount");
I'm using Jgrasp and my prompt is asking me to write a program where the program prompts the user to enter 4 grades between 0 and 100. And you have to display the grades, and the program has to calculate the minimum grade, the maximum grade and the average.I'm just having problems with the max?
// Import Java Scanner. import java.util.Scanner; // Name Class. public class Practice_4_1
Write a program (TwoIntegers.java) that prompts the user to enter two positive integers and prints their sum (by addition), product (by multiplication), difference (by subtraction), quotient (by division), and remainder (by modulation). When the user enters 5 and 3, the output from your program should look exactly like the following:
Enter two positive integers: 5 3 The sum is 8. The product is 15. The difference is 2. The quotient is 1. The remainder is 2.
import java.util.Scanner; public class TwoIntegers { public static void main(String[] args) { System.out.println("Enter two positive integers: "); Scanner userInput = new Scanner("System.in"); int integer1 = userInput.nextInt(); int integer2 = userInput.nextInt();
My homework is asking me to write a program that prompts the user to enter a password and displays "valid password" if the rule is followed or "invalid password"
Sample enter a string for password: wewewx valid password
It's being graded on Design of my GUI Dialog box User friendliness Creativity
My current issues with the current code I have written is simply the password doesn't work unless it starts with 2 digits, the other order it displays as wrong. and I have no idea how to add a GUI.
Write a program called ProductCatalog that prompts the user to enter the number of products in the product catalog. The program should then prompt the user for the name and the price of each product in the product catalog. Once all of the products have been entered, the program should output the product information (name and price) of the most expensive product in the catalog. Your solution must use a for loop repetition structure and should use the Product class included in labfiles05.zip to keep track of the product with the highest price. Here is sample output:
Enter the number of products: 3 Enter the name of product 1: iPod Enter the price of product 1: 158.99Enter the name of product 2: iPad Enter the price of product 2: 518.99 Enter the name of product 3: iPadMini Enter the price of product 3: 304.49 Most Expensive: Product [name=iPad, price=518.99]
Your solution should not use an array to keep track of all the product information entered.
I am having trouble with my code, with the For loop and then calling the methods from the Product class into the ProductCatalog. How should I approach this program.
Here is the Product program.
public class Product { private String name; private double price; public Product(String theName, double thePrice) { name = theName; price = thePrice;
[Code]...
Here is the ProductCatalog class where I call the methods from Product class. The For loop is what I am having trouble with as well.
import java.util.Scanner; public class ProductCatalog { public static void main(String[] args) { double number; String product = " "; double productCount = 0;
Create a Java application that prompts the user to enter their personal details: First name, last name, gender, address, suburb, postcode, and phone number. Then the program displays all of your personal details to the screen as illustrated. Name the file PersonDetails.jav
package exe import java.util.*; public class Review2 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter your full name: "); String name = scanner.next();
[Code]...
If you cant tell straight away how i have stuffed up, what is happening is this;
When i am promoted to enter my name, 'John Smith'. The word 'John' would be stored in the name variable, while 'Smith' is stored under gender, so the next prompt is then 'Whats your address?'
So its only assigning one word per variable, now as far i understand, a string should not work that way. So where is my mistake?
This is the other code problem I have. The user should be able to enter the amount of digits the array should be shifted left. For example, if the user entered 3 and the array was 1 2 3 4 then it should return 4 1 2 3. here is my code.
public char[] replaced(char[] array, char oldChar, char newChar) { char myFun[] = new char[array.length]; for (int i = 0; array.length > i; i++) { myFun[i] = array[i];
Here's the small project... but how can I return the value (amount) in 10 years ? The way I did, the program just doesnt return anything...
import java.util.Scanner; public class FutureValue { public static void main (String []args) { double amount = 0; double apr = 0; System.out.println("How much money would you like to invest?");
1. Write a Java program that randomly generates a five-digit lottery number and prompts the user to enter a five-digit number. Each digit in the number is in the range between 0~9. The program should determine which prize the user wins according to the following rule:
- The user wins the first prize if the user input matches all five digits in the lottery number in exact order. -The user wins the second prize if the user input matches any four digits in the lottery number in exact positions. -The user wins the third prize if the user input matches any three digits in the lottery number in its exact position. -The user wins the fourth prize if the user input matches any two digits in the lottery number in its exact position.
- The user wins the fifth prize if the user input matches any one digit in the lottery number in its exact position.here is my code. I have tried replacing the && statements with || and it always returns either case 1 or case default.
import java.util.Scanner; import java.util.Random; class Hw5 { static int getPrize(int g1, int g2, int g3, int g4, int g5, int u1, int u2, int u3, int u4, int u5) {
So i need to write a program that prompts the user for 3 double numbers x, y, z that outputs 2x^3 + 3y^5 + 3x^3y^2 +xyz with
(1) 4 digits precision (2) with a ',' to separate thousands (3) all digits of the result including the precision are put to 20 positions (from right to left)
I am not really sure what it is suppose to look like or how to start it.how to mix Math.pow with multivariable and printf.
Write a Java program that randomly generates a five-digit lottery number and prompts the user to enter a five-digit number. Each digit in the number is in the range between 0~9. The program should determine which prize the user wins according to the following rule:
• The user wins the first prize if the user input matches all five digits in the lottery number in exact order. • The user wins the second prize if the user input matches any four digits in the lottery number in exact positions. • The user wins the third prize if the user input matches any three digits in the lottery number in its exact position. • The user wins the fourth prize if the user input matches any two digits in the lottery number in its exact position. • The user wins the fifth prize if the user input matches any one digit in the lottery number in its exact position.
and here is my code. I cant get it to print the right statements.
import java.util.Scanner; import java.util.Random; class Hw5 { static int getPrize(int g1, int g2, int g3, int g4, int g5, int u1, int u2, int u3, int u4, int u5) { //code for determining the prize comparing (g1, g2, g3, g4, g5) to (u1, u2, u3, u4, u5) if (u1 == g1 && u2 == g2 && u3 == g3 && u4 == g4 && u5 == g5)
I need to write a simple program that reads an amount of minutes and displays the approximate number of years and days for the minutes. For simplicity, assume a year has 365 days and the resulting amount of days is a whole number.
In the following piece of code Iam trying to display the the loan amounts of the various loan objects located in a binary file. Iam trying to do his using getLoanAmount() in the loan class. the program is compiling but nothing is showing up on he console.
Program import java.io.*; public class Exercise19_06 { public static void main(String[] args) throws ClassNotFoundException, IOException { ObjectOutputStream output = new ObjectOutputStream( new FileOutputStream("loan.dat"));
so I had to create a program that allows the user to enter a day using a number and then enter a year and after they did that it would create an entire calendar for that year ..so I have that but the only issue is I can not get the numbers to line up neatly.how to do the entire thing in loops, I tried a couple in here..what this would look like as loops instead of switches and cases and if else
import java.util.Scanner; public class Calendar { public static void main(String[] args) { Scanner scanner = new Scanner(System.in);
package question.pkg3; import java.util.Scanner; public class Question3 { public static void main(String[] args) { // TODO code application logic here Scanner Luka=new Scanner(System.in); double sum=0;double count=0; int[] a=new int[10];
[code]....
I'm required to write a program that allows the user to enter up to 10 integer grades into an array. Stop the loop by typing in ‐1. Your main method should call an Average method that returns the average of the grades.I There's something wrong with my program , the count always stays 0 and the sum is always 1 less than the actual sum.Sample input and output :
Enter grade 1: 8 Enter grade 2: 9 Enter grade 3: 10 Enter grade 4: 5 Enter grade 5: 8 Enter grade 6: 9 Enter grade 7: -1 output
Average grade is 8.1666666667On line 13 I had count=count+1 ;
I have to meet certain requirements for this one program, and one of them is as follow: The program will require the user to enter the needed values one after another. If any of the entered values is invalid, then the program will detect that and go into a loop requiring the user to enter a valid value. The program must keep track of the total number of invalid values that the user has entered.
I know how to set a restriction and create a loop to keep asking the same question until it is satisfactory ( in this case I used a while loop) but I am at loss on how I should keep track of the total number of invalid values. I know I can use an increment but how do I set a variable for when the program meets an wrong input from the user.
I am writing a short quiz program, and when the user inputs their answer they hit the enter key (the are int). But the last question on my quiz is asking the user to they want to repeat the quiz, but when I run the program, it won't allow me to input any information. I can briefly remember my lecturer saying something about entering in a code after each int the user inputs but I can't remember what it was.
Here is a snippet of my code:
//Question 3 do{ System.out.println("Question 3- What Hollywood actor did Mila Kunis have a baby with recently?"); System.out.println( question3 + ".Ashton Kutcher 2.Bradly Cooper 3.Leonardo Dicaperio h.Get a hint"); answer3 = stdIn.nextInt(); if(answer3 != question3)
I am trying to write a program that asks the user to enter a number from 1 through 10 and then the program will display the roman numeral for that number.
I am also adding a error message in which i haven't yet because im still trying to figure out how to the program will do the roman numeral.'
I have used the if and else if. but when i input a number it just repeats the number back to me.
The program cimpiles but it doesn't do what i want. here is what i have so far. how can i get the program to display the roman numeral after the number is entered.
import javax.swing.JOptionPane; public class Romannumeral { public static void main(String[] args) { double number;
I did a problem from my book which is "Write a method that displays an n-by-n matrix. Each element is 0 or 1, which is generate randomly. Write a test program that prompts the user to enter n and displays the n-by-b matrix".
So if a user would enter 3, and output could be 0 1 1 0 1 0 1 0 1
So here's my question... I was able to get the program to work in the way my book describes (by just writing the code in the class with the main), but for practice, I want to learn how to do this OOP-style...
I'm not sure how to do this, though, since the method is a void method, so I can't seem to call it within a toString method.
import java.util.Scanner; public class MatrixTest { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter an int"); int number = input.nextInt(); MatrixClass mc = new MatrixClass(number);
Ok so I have my program working for the most part. In this program I am supposed to take input from the user until they enter a negative number and that works, the problem is that it doesn't work if I enter a negative number on the first prompt. For example if I enter a 100 it would prompt me again and if I enter a negative number it would quit and give me the average, but if I enter a negative number the first time I am prompted the program just gives me an error. How do I fix that?
import java.util.List; import java.util.ArrayList; import java.util.Scanner; public class Application { public static void main(String [] args){ Scanner input = new Scanner(System.in); List<Integer> grades;
{ public static void main (String []args) { Scanner numberin = new Scanner (System.in); double store [];
[Code]....
How would I get my program to display a * for every 100 dollars in sales that the user enters in so: for example the user enters in store 1: $ 400 in sales for the store I want it to display store 1:****
The first part of my code allows the user to enter in whatever values the stores have in sales. The Second half of the code starts at line 19 is my best guess on what I need to do I just am not sure how to get it to display what I need it to.
Write a program that reads in a line of text and then outputs that line of text first in all uppercase letters and then in all lowercase letters.
INPUT and PROMPTS. The program prompts for a line of text as follows: "Enter the text: " and then reads in an entire line of text as a String .
OUTPUT . There are four lines of output . The first line is "The text in all upper case is: ". The second line is the line that was read in, displayed in all uppercase. The third line is "The text in all lower case is: " and the fourth line is the original line that was read in, displayed in all lowercase.
CLASS NAMES. Your program class should be called ShoutAndWhisper.
[import java.util.Scanner; public class ShoutAndWhisper { public static void main(String[] args) { Scanner scannerObject = new Scanner(System.in);
I've four classes object. I don't know how to display the amount paid by the user, and show the balance. The calculate button just show the total amount. Do I have to create another object class? And I've to show the bills too.
This is my 1st Frame
import javax.swing.*; import java.awt.*; //titlepanel class displays a title in a panel public class TitlePanel extends JPanel { public TitlePanel() { JLabel title = new JLabel();
I created my own class and it basically randomizes the amount of 'spells' [magic] a user uses (range 1-5). I can't figure out how to increment the initial randomized output to make something like this :
User X : uses 2 spell. User Y : uses 3 spells.
User X : uses 3 spells. (Taking the randomized 2 and increment by 1) User Y : uses 4 spells. (Taking the randomized 3 and increment by 1)
My current setup looks like this : First one is the class I created and the second one is just how the output would look like. (seperate by +++++...)
My goal is to create a METHOD to increment it.
public class Spell { // Max number of spells private final int MAX_FACE_VALUE = 5; // Current face value private int faceValue; // New instance of Spell public Spell() { faceValue = 1;
[Code] ....
+++++++++++++++++++++++++++++++++
public class SpellOutput { public static void main(String[] args) { //Object creation Spell spellCasterOne = new Spell(); Spell spellCasterTwo = new Spell(); Spell spellCasterThree = new Spell();
I have a simple java program to write which tells the user combination of coins that equals to the amount of change i.e:
user input 87
output:
3 quarters 1 dime 0 nickels 2 pennies
How the program remembers the remainder which is passed to the next column of let say dime
i.e
originalAmount = amount; quarters = amount /25; amount = amount % 25; <---- this is confusing for me?!?! how can the integer = integer % 25 dimes = amount / 10; <--- HOW THE PROGRAM remembers the "remainder" instead of the original user input as the code it self tells you dimes = amount where "amount" is what user input NOT remainder.
amount = amount % 10; so on ....;
What I don't understand is HOW this algorithm works. I mean we have int amount where user inputs the number we get the first calculation amount/25 = how many quarters and then amount %25 WILL tell us about the reminder. By looking at this piece of code I would say that the system should start the calculation for the dimes again from the original number since the code says dimes = amount/10 AND amount = amount%10. My understanding is that the calculation should be done from the original user input.
Book or code it self is not clear for me how the reminder is "REMEMBERED" and then pass on to the next calculation>!?!?
UNLESS the code: amount=amount%25 gets the remainder so the next code under it is REQUIRED to read from the last prompt code.