Loan Calculator - How To Round Decimals

May 20, 2014

I'm currently working on a loan calculator... The only problem I'm having is occasional values that have very long decimals... How do I round the decimals?

View Replies


ADVERTISEMENT

Amortization Algorithm - Loan Calculator That Uses Compound Interest

May 21, 2014

I'm making a loan calculator that uses compound interest... I need the program to return the monthly payment, how much of it is principal and how much of it is interest, which depends on how many months into your loan you are... So basically all I need is the algorithm to calculate how much of your monthly payment (depending on how many months in you are) is interest and how much of it is principal.

View Replies View Related

Display Loan Amounts Of Various Loan Objects Located In Binary File

Dec 6, 2014

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"));

[code]....

View Replies View Related

Get Answer To Only Show Two Decimals

May 25, 2014

I have tried as much as I can to place code to give me only two decimals in answers but cannot get it to work not sure if placement or syntax.This is code so far and it works but gives answers to 8 decimals.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

[code]...

View Replies View Related

Program Is Supposed To Operate On Decimals

Mar 31, 2015

My program is supposed to operate on decimals because it concerns volume of packagings. I learnt that what normally is simple arithmetic (100 cm × 75 cm × 60 cm = 0.45 m³) in Java gives only approximate value (something like 0.44(9) m³ in this case). That's close enough so I probably shouldn't worry, but the thing is that although for one packaging the difference is barely visible—if at all—for thousands of packagings it'll make a difference. It'll be worse when I get to counting money.

I found two solutions:
1) Using integers and so-called decorative decimal point on display. I have a bad feeling about this, though.
2) Using BigDecimal.

Now, BigDecimal seems like a nice solution. I tried it and so far it looks okay. But just look at an excerpt from my program that I had to re-write (previously it looked perfectly fine as a single line):

volume = dimensions
.get("Length").multiply(dimensions.get("Width")
.multiply(dimensions.get("Height")))
.divide(new BigDecimal("1000000"));

I'm using a HashMap to store dimensions. I figured it'd make it easy for me to manage and display data later on.

View Replies View Related

Roman Numeral Conversion To Decimals

Jul 29, 2014

I have made a program that is supposed to convert roman numerals to decimals. It is NOT supposed to convert decimals to roman numerals. The only problem it seems there is with the program is that it only adds and does NOT subtract. This causes some roman numeral conversions to be flawed. What can I try to fix this. Keep in mind that the reason some methods exist is because the directions for the code say that I have to make it this way.

Instructions:

Write a program that converts a number entered in Roman numerals to decimal. Your program should consist of a class called Roman. An object of type Roman should be able to do the following:

1) Store the number as a Roman numeral.
2) Convert and store the number into decimal.
3) Print the number as a Roman numeral or decimal number as requested by the user. (Be sure to over-ride the toString function).
4) Your class must contain the method romanToDecimal to convert a Roman numeral into its equivalent decimal number.
5) Test your program using the following Roman numerals: MCXIV, CCCLIX, and MDCLXVI.

This is what I have so far. It compiles and there are no errors, but it does not subtract I from X, or I from V and so on. For example,CMXLVII should be 947, but the program outputs 1067.

import javax.swing.*;
import java.util.*;
public class Roman{
private String roman;
private int decimal;
public int romanToDecimal(String s)

[Code] .....

View Replies View Related

Formatting Decimals (Two Temperature Values)

Jan 30, 2015

I'm trying to format two temperature values using String.format.

return String.format("% 5.1f", temperature) + 'u2109' + " / " + String.format("% 5.1f", temperature2) + 'u2109';

I need all of that to be combined into a single String.format and include the / and unicode symbols for degree fahrenheit. How String.format works so that I can figure out how to achieve that? I've tried a few websites but none of them explain it to the extent that I need to use it.

View Replies View Related

Construction Loan - No Main Class

Feb 13, 2015

I keep getting an error every time saying there is no main class ...

Loan

public class Loan implements LoanConstant{
public static int loanNumber;
public static String lastName;
public static int loanAmount;
public static int interestRate;
public static int term;
public int primRate;

[Code] ....

View Replies View Related

Converting Meters To Feet - How To Print Decimals

Oct 1, 2014

I am making a small program that converts meters to feet. I want my answer to be printed with 2 decimals, but I am struggle. This is my current code, any takes on what needs to be changed and why?

import java.util.Scanner;
import java.text.DecimalFormat;
public class Chapter2PE3 {
public static void main (String[]args){
Scanner input = new Scanner (System.in);

[Code] ....

View Replies View Related

Calculate Time For Loan Payment - Writing Java From Pseudocode

Nov 26, 2014

calculate how long it would take to pay off a loan of 500 pounds if there was 10% interest monthly, and 100 pounds was paid each month. This code is in a pseudocode,

set months = 1
set balance = 500
set totalpaid = 0;
while balance > 100
balance = balance - 100;
set interest = balance * 0.1
balance = balance + interest
totalpaid = totalpaid + 100
months = months + 1
endwhile
totalpaid = totalpaid+balance
display "you paid "+totalpaid
display "It took you "+months+" months"

View Replies View Related

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");

[Code]...

View Replies View Related

How To Round The Numbers

Sep 27, 2014

The first problem is that the numbers don't round in IntelliJ.

Example: ('s in Dutch)
Geef de vorige kilometerstand: 125
Geef de huidige kilometerstand: 900
Geef het aantal getankte liters: 50
Verbruik voor 775km: 6.451612903225806/100km

That 6.4516..... is the problem, how can I make it 6.45/100km?

View Replies View Related

Round Up Double Numbers To Desired Value?

Mar 28, 2015

I have a double/big decimal value with 2 decimal places....What I want is that if decimal value is .01 - .49, it should round up to 0.50.

Then if decimal value is between 0.51 - 0.98, it will round up to 0.99.

Is there a function in double that can do this? How can I do this?

View Replies View Related

How To Round The Result To Nearest Integer

Jan 11, 2015

My program is attempting to:

1. ask user to input a decimal
2. output 1 - confirms the input
3. output 2 rounds the input value to the nearest integer.

Here is what I have so far:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.Scanner;
public class IT145Exercise13 {
static Scanner console = new Scanner(System.in);
 
[Code] .....

Results with input of 5.25:
run:
Enter a decimal:
5.25
You entered 5.25

The integer value is 5 YES however,

BUILD SUCCESSFUL (total time: 6 second)

However, if the input is 5.95 here are the run results:

run:
Enter a decimal:
5.95
You entered 5.95
The integer value is 5 Here I expect 6
BUILD SUCCESSFUL (total time: 6 second

Not sure how to ask the output of the variable integerOut to be rounded to the nearest integer?

View Replies View Related

Standard Deviation - Round To 10s Place

Dec 2, 2014

for standard deviation my output is not rounded to the 10's place, how can I make it round to the 10's place. Here is my code.

import java.util.*;
public class chapter7 {
public static final int Max_Number_Scores = 100;
public static int fillArray(double[] scores) {
System.out.print("You entered ");
for (int i = 0; i < scores.length; i++) {
System.out.print(scores[i] + " ");

[code]....

View Replies View Related

Efficient Method To Round Double On 0.05

May 27, 2015

I've a question on rounding doubles on 0.05 As far as i know there is no class method that is able to do this. To achieve this rounding i have the following code:

Example:
164.67 -> 164.70
173.33 -> 173.35
0.02 -> 0.05 

double calculatedQuantity = 0.0;

  // Formula to calculate the average working hours in a month
  int totalWeeksInYear = 52;
  int totalMonthsInYear = 12;

[Code].....

View Replies View Related

JavaFX 2.0 :: Round Corner In TableView Header

May 20, 2014

I'm doing a bit of styling in TableView. The result is quite nice but I can't make the left top corner round. This is the actual result:
 
[URL] ....
 
And this is the css :

.table-view {
    -fx-background-color: transparent;   
}
/*HEADER */
.table-view .column-header{      

[Code] .....

I would also like the top left corner was round.

View Replies View Related

Will SP Call From Java Make 2 Round-trips To DB?

Feb 5, 2014

We are in the process of developing a e-commerce application. It is a web site for a book shop. It is a site very similar to Amazon.com where you can order books online.  Front end is in Java Technology.  There is however a concern about where to put the business logic.
 
I am suggesting to put all business logic in the Oracle Database, as stored procedures (i.e. packages). However, one of my colleague says that when you call a Oracle stored procedure from Java, it takes 2 round trips, one to validate the procedure and then to validate the input / ouput parameters of the procedure.
 
In a website application like what we are trying to build, is it sound advice to put all business logic in the DB? Or should it be in the middle tier (app. server) programmed in Java? Or should you spread in between the middle tier and DB? If so how?

View Replies View Related

Round Decimal Number Into 2 Decimal

Apr 2, 2014

Here is my code and i want to convert number into 2 decimal but this code not give me result how to check my code.

import javax.swing.JOptionPane;
public class showtime{
public static void main(String[] args){
double total_mili=System.currentTimeMillis();
JOptionPane.showMessageDialog(null,total_mili, "Total milisecond",JOptionPane.INFORMATION_MESSAGE);
double seconds=total_mili/60;
double sec=(double)(seconds * 100) / 100.000;
JOptionPane.showMessageDialog(null,seconds, "Total Second",JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null,sec, "Total Second",JOptionPane.ERROR_MESSAGE);
}
}

View Replies View Related

Tip Calculator For Fun

Oct 18, 2014

So, I'm working on a Tip Calculator for fun. I have everything worked out for the most part. The feature I am trying to add is to give the user the amount of change they'll get back from their transaction. I do not ask the user any information other than what is their bill.

Please enter your bill total : 5.50
Please enter your name : some name
Total : 5.50
Tax : 0.48 -- Based off a tax rate of 8.75%
Total with Tax : 5.98 --
20 percent Tip : 1.10
Total with Tax and 20 percent Tip : 7.08
Total change : <-- I believe this will be about $2.92

I want the total bill to round to the nearest $10 value (e.g. for $5.50, calculate bill to $10. For $13.00, calculate bill to the $20.00, and so on... This way I get an accurate amount of change to give back to the user.

View Replies View Related

MVC Calculator - How To Get It To Actually Calculate

Sep 28, 2014

I made a MVC calculator. I was wondering if you could take a look at my design and if I was on track. I am still working on getting it to actually calculate something. All the buttons respond and print text on the JTextField but it is not calculating.

package calculator.MVC;
import javax.swing.JButton;
import javax.swing.JTextField;
public class CalculatorModel {
private int sum;
private int number;
private char opt;

[code]....

View Replies View Related

Calculator Only Return 0.0?

Sep 2, 2014

I am making a calculator in Java. However, when I press the "=" button on my calculator, it always returns 0.0, no matter what. I don't understand why? The code is below:

import javax.swing.*;//import the packages needed for gui
import java.awt.*;
import java.awt.event.*;
import java.util.Arrays;
import java.util.List;
import static java.lang.Math.*;
public class CalculatorCopy {

[Code] ....

View Replies View Related

How To Add Loop In Calculator

Mar 11, 2015

import javax.swing.*;
public class BasicCalculator{
public static void main (String[] args) {
String output="";
double n1,n2;
String operation;
operation= JOptionPane.showInputDialog("Please enter your operation");

[Code] ....

How to add a loop in this problem:

View Replies View Related

While Loop Pay Calculator

Dec 2, 2014

I have the basic workings of this program just doing all the printing at the end is throwing me off. Anyway here are some of the requirements and my code:

1. Allow the user to input an individual's hours worked.
2. Accumulate the total regular hours worked, the overtime hours worked, the amount of the regular pay, the amount of overtime pay, and the total payroll, for all of the employees entered.
3. Allow the user to enter a zero (0) as the Boolean expression to end the loop.
4. When the loop ends print out all of the accumulated totals with appropriate labels, each on a separate line.

import java.util.Scanner;
public class WhileLoopPayCalc
{
public static void main(String [] args)
{
final double REGULAR_HOURS = 40f;
final double HOURLY_WAGE = 12.5f;
final double OVERTIME = 1.5f;

[code]....

View Replies View Related

Calculation In Awt Calculator

Jul 10, 2014

I am facing problem during calculation in my awt calculator. It is showing NumberFormatException. Below is part of code.

if(e.getSource()==b14)//On button 14, label is "/"
{
String v1=tf.getText().toString();
num1=num1+Integer.parseInt(v1);//num1 is as integer variable
tf.setText("");//tf means textField
}else

[code]....

View Replies View Related

Calculator In Java

Oct 28, 2014

I can not this to work correctly.

public static void main(String[] args) {
FloatWrapper x1=new FloatWrapper(0);
FloatWrapper x2=new FloatWrapper(0);
do{
switch(menu()){
case 'a': if(dataInput(x1,x2)) add(x1,x2); break;
case 'b': if(dataInput(x1,x2)) subtract(x1,x2); break;

[code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved