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?");
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 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.
I want to use a method, which takes for example an int and also returns an integer. For example, if the the given integer is strong return a, if it is notstrong return b. How would you write that in a Code?
I want to use that in a more general way. I want to give a method mlong the value X of the type date and let it return an int. Type date consists of 3 int, one of them is the int month.
mlong should return an int depending on the X.moth. at the moment my code looks like this:
// File1: public class date { public int day; public int month; public int year; }
// File 2: public class monthlength { public int mlong(date X) { int t; t = X.month; if (t == 1 || t == 3 || t == 5 || t == 7 || t == 8 || t == 10 || t == 12) { return 31; } if(t == 4 || t == 6 || t == 9 || t == 11) {return 30;} } }
For this program I am calculating the annual costs of 5 office supplies (user input) each with a 5.7% inflation. The user inputs the cost of each object and my program must calculate and display the price of each object each year for 5 years. I already have this part. What I need is how to add the total costs of all 5 supplies per year and display each total cost. Here is the program:
import java.util.Scanner;//Using keyboard to enter data //Start of Class public class OfficeSupplyCalculator { //Start of Method public static void main(String args[]) { Scanner keyboard = new Scanner(System.in); System.out.println("Enter the first item");
[Code] .....
At the moment all I get for the grand total loop is the same number showing up 5 times. I feel like the problem is how I am declaring the grandtotalperyear variable but I'm not sure what is wrong.
import java.util.Scanner; public class days { public EnumTest () { this.day = weeks/months/years} final int daysInMonth = 30; //constants final int monthsInYear = 12; final int daysInWeek = 7; public void convert()
[Code] ....
after compiling it shows invalid method declaration ; return type required.
How do i take input values for TwoDPoint (which are objects) and return it back in numerical values also print them.
When i create an object in main method and pass values to my function of return type TwoDPoint,it gives error:- found int,int need TwoDPoiint,TwoDPoint.
// Here is what i tried to do:
Created class TwoDPoint that contains two fields x, y which are of type int. Defined another class TestTwoDPoint, where a main method is defined.In the main method created two TwoDPoint objects.
Then I modified the class TestTwoDPoint and add another function to it. This function takes two TwoDPoints as input and returns the TwoDPoint that is farthest from the point (0,0).
Then I added another function to TestTwoDPoint. This function takes two TwoDPoints as input and returns a new TwoDPoint whose x value is the sum of x values of the input TwoDPoint's and whose y value is the sum of the y values of the input TwoDPoint's.
class TwoDPoint { int x = 2; int y = 4; } class TestTwoDPoint { public static void main(String args[]) { TwoDPoint obj1 = new TwoDPoint(); System.out.println(obj1.x); System.out.println(obj1.y);
I am trying to make a program that get input value 1-200 from user. However I would like to make the program to show warning if the input number is not within the range of 1-200. In the end I would like to show the amount of number according to its interval (i.e less 50, 51-100 and so on) ....
import java.util.Scanner; class test { public static void main (String[] args) { int number[]= new int[5]; int number2[]= new int[5]; int a=0,b=0,c=0,d=0,i=0;
I am having is not being able to print out the diamond the amount of times the user enters (for example, when it asks how many diamonds, I enter a 2 and only one diamond comes out.)
import java.util.Scanner; public class Pattern5 { public static void main(String[] args) { // For this pattern program, ask the user how many diamonds // she would like to print to the screen. The following pattern is one diamond.
Ii am trying run a do while loop on java a specific amount of times for example if i were to type in "Enter number of years" and enter 4. i need the loop to execute 4 times or if i said 6 times then i would be 6. the program i have repeats it and takes it back to reentering "Enter number of years" i need it to execute by its self x amount of times. here is what i have so far
System.out.println("Enter the number of years: "); years = keyboard.nextInt(); rainfall = generator.nextInt(10) + 1; System.out.println("Year " + "rainfall amounts were");; for (int months = 1; months <= 12; months++)
public static void main(String[] args) { boolean t=false; long cuTime = System.currentTimeMillis() while(t==false) { System.out.println(cuTime); long g=cuTime+2000;
[Code] ....
I tried this and it includes a while loop as the whole program has to wait until this while loop executes. So the entire program slows down. Is there any way to do this without a while loop
public static void main(String[] args) { boolean t=false; long cuTime = System.currentTimeMillis(); while(t==false) { System.out.println(cuTime); long g=cuTime+2000;
[Code] ....
I tried this and it includes a while loop. therefor the whole program has to wait until this while loop executes. So the entire program slows down. Is there any way to do this without a while loop...
I am trying to make a program to multiplies two numbers without using the "*" operator. My idea was to add x number y amount of times, which is the same as multiplication. I did this with a for loop, but zero is always returned as the answer. How can I fix this?
public class secondMult { public static void main(String[] args){ System.out.println(multWithSum(4,5)); } public static int multWithSum(int x, int y){ int sum = 0; for(int i = 0; i==y;i++){ sum = sum + x; } return sum; } }
public static void main(String[] args) { boolean t=false; long cuTime = System.currentTimeMillis(); while(t==false) { System.out.println(cuTime);
[code].....
I tried this and it includes a while loop as the whole program has to wait until this while loop executes. So the entire program slows down. Is there any way to do this without a while loop
I want to use a method, which takes for example an int and also returns an integer. For example, if the the given integer is even return 1, if it is not even return 0. How would you write that in a Code?
I want to use that in a more general way. I want to give a method mlong the value X of the type date and let it return an int. Type date consists of 3 int, one of them is the int month.
mlong should return an int depending on the X.moth.
At the moment my code looks like this:
// File1:
public class date { public int day; public int month; public int year; }
// File 2:
public class monthlength { public int mlong(date X) { int t; t = X.month; if (t == 1 || t == 3 || t == 5 || t == 7 || t == 8 || t == 10 || t == 12) { return 31; } if(t == 4 || t == 6 || t == 9 || t == 11) {return 30;} } }
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 have to write some code to take names from the user and then order them in alphabetical order and then print them out which i have managed to do. However, i can't get it to count the characters in the names that the user enters or count the amount of vowels in the names.
This is the code ive written:
import javax.swing.JOptionPane; import java.util.Arrays; String[] names = new String[9]; int i; names[0] = JOptionPane.showInputDialog("Please enter a name"); names[1] = JOptionPane.showInputDialog("Please enter a name");
gather sales amount for the week display the total of sales display the average of sale display the highest sale amount display the lowest sale amount
using occurrences determine how many times the amount occurred for the week
make a sales main make a sales data
This is what i have so far but I'm confused on how to start the occurrence and where it would be placed in order to get the information from the array
public class SalesData { private double[] sales; // The sales data /** The constructor copies the elements in an array to the sales array. @param s The array to copy. */ public SalesData(double[] s) {
I have a question about how to delete only a certain amount of objects on screen in a graphics window. I have a method that will enable me to get rid of every object of the same type off screen, for example this method:
Java Code:
public void deleteTrees() { //clears all tree trunks and leaves for (Iterator<GRect> it = historyT.iterator(); it.hasNext();) { GObject gobj = it.next(); this.remove(gobj);
[Code] ....
That Will delete all trees.
Now In my main method I populate the screen with trees by doing this
My question is how to specify only deleting x amount of trees instead of the whole thing. I pretty sure I need to use something like history.remove(trunk) and to iterate through the amount of trees specified, but not sure how to implement that.
I'm doing this project in JSP.net, with html. and in one of the web pages, what I'm doing is that, a person is transferring an amount to someone else, and if the transfer amount is more than the account balance, then he cannot transfer. else, save details in a table.
Here's the code I've used
<% String t1=request.getParameter("text1"); String t2=request.getParameter("text2"); java.util.Date date1 = new java.util.Date(); SimpleDateFormat ft = new SimpleDateFormat ("dd/MM/yyyy"); int tamt = Integer.parseInt(t2); int bamt = 0;
[Code] .....
But when i enter the fields and click the submit button in the form, to save it in the table, i get the error: