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


ADVERTISEMENT

Writing Java From Pseudocode

Nov 26, 2014

for x = 0 to 9
set stars = "*"
set count = 0
while count < x
stars = stars + "*"
count = count + 1
endwhile
display stars
endfor

I need to change this pseudocode to Java, but I'm new, been trying for ages but can't get it right.

View Replies View Related

Program That Calculate Minimum Fixed Monthly Payment

Jun 11, 2014

I want to Write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance.

the Amount is 3,500 the annual rate is 9.9%, the minimum payment is 2% a month. the fixed payment is 150.

By a fixed monthly payment, we mean a single number which does not change each month, but instead is a constant amount that will be paid each month.

The program should print out :

payment information:
new balance total .......
current payment due .......

if you make minimum payment (2%) you will pay of in .... months and you Will end up paying an estimated total of $........

if you make the fixed rate payment, you will pay of in .... months and you Will end up paying an estimated total of $........ and you will save $........

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

Servlets :: Payment Gateway In Java

Jan 20, 2011

How to implement the payment gateway in java.

View Replies View Related

Writing Current Time To Text File

May 29, 2014

I'm working on a project for class that asks me to record punch-in and punch-out times for employees. However, I am having difficulty figuring out where I am going wrong as none of the information will write to the text file in the ArrayList that I have created. The code is as follows:

import java.text.*;
import java.util.*;
import java.io.*;
import java.nio.file.*;
public class TimeClockApp {
// declare class variables
private static EmployeeDAO employeeDAO = null;

[Code] .....

I want to keep the coding as simple as possible as I am new to Java, and have spent hours upon hours trying to figure this all out. The console output looks like this:

Welcome to the Punch-In/Punch-Out Screen

Please choose an option below:

I. Punch In
O. Punch Out
Choice: i

PUNCH IN
--------
Enter Employee ID:
8
8Punch-In Date & Time: 2014/05/28 22:44:26
[]
Press enter to return to the main screen:

View Replies View Related

Simulate Airport - Calculate Average Time A Plane Stays Inside A Queue For

Nov 13, 2014

Write a program to simulate this airport's operation. You might assume a simulated clock that advances in one-minute intervals. For each minute, generate two random numbers: If the first in less than LandingTime /60, a "landing arrival" has occurred and is added to the landing queue, and if the second is less than TakeOffTime /60, a "takeoff arrival" has occurred and is added to the takeoff queue.

Next, check whether the runway is free. If it is, first check whether the landing queue is nonempty, and if so, allow the first plane to land; otherwise, consider the takeoff queue. Have the program calculate the average queue length and the average time that an airplane spends in a queue.

I have most of the code done as you can see below:

* Queue Interface: Queue.java
* Queue Implementation: ArrayQueue.java
* Demo Program: Airport.java

Right now, I am stuck on the first calculation which is trying to figure out the average size of the landing queue. For some reason, as you can see at the bottom of my demo program, the average always comes out to be 0.0 and I'm not sure what's wrong.

Secondly, how to calculate the average time a plane stays inside a queue for.

View Replies View Related

Insertion Sort Pseudocode

Jan 1, 2014

I can't spot where my java implementation of insertion sort differs from the pseudocode here:Well, there is one difference in the parameters used by the insert method, which is inconsistent in the pseudocode.I'm pretty sure it should be calling insert (a,n) instead of (a,i,n);

insert(a,k) i←k
x ← a[k]
while x < a[i − 1]
x ← a[i]
a[i ] ← a[i − 1] i ←i −1
a[i]←x return

insertion-sort(a,n)
m ← select-min(a,1,n) swap(a,1,m)
fori from2upton
insert(a,i,n) return

Here is my attempt at a java implementation, which doesn't actually seem to do anything.I've kept variable names as in the pseudocode. Might technically be bad practice, butI think it should make it easier to follow in this particular scenario.public class InsertionSort {

public static void main(String[] args) {
int[] array = { 99, 2, 44, 14, 14, 44, 11, 33, 14, 14, 51 };
insertionSort(array, 10);
for (int i : array)
System.out.print(i + " ");

[code]...

Why am I so interested in this pseudocode when there are simpler java-ready examples of insertion sort on the internet? Simply because this is the code the professor uses, so I should be able to understand it.

View Replies View Related

Pseudocode For Quicksort Algorithm

May 6, 2015

I have been given this Pseudocode for the Quicksort algorithm:

quicksort(a[], p, r)
if r>p then
j=partition(a[], p, r)
quicksort(a[], p, j-1)
quicksort(a[], j+1, r)

[code]....

I was wondering why:

- why the condition left < right needs to be true for the while loop in the function Partition
- what the while loop does in the function Partition

View Replies View Related

Mortgage Calculator - Monthly Payment Is Not Getting Out Correctly

Sep 25, 2014

This is for a mortgage calculator and we have to use the math.pow method. I am getting results, but the results are wrong. The monthly payment is coming out to big.

Here is what it should be:

Enter loan amount: 10000
Enter rate: 4.5
Enter number years: 3

The monthly payment is: $297.47

Here is what I'm getting.

Enter loan amount: 10000
Enter rate: 4.5
Enter number years: 3

The monthly payment is: $566.06

Here is my code. I believe my issue is in the math.pow formula.

Scanner in = new Scanner(System.in); // input object

double loanAmount; //user input
double interestRate; // user input
double yearNumber; // user input
double monthlyPayment; // answer to math
double finalPayment; // output
double monthNumber; // year number converted of months
double monthlyRate; // converted intersted rate

[Code] ....

The monthly payment is: $%.2f", monthlyPayment); // Shows monthly payment

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

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 View Related

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

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

Writing A Java Program To PRINT?

Oct 19, 2014

how to print from bluej onto actual paper? how to do the formatting and configuration etc.

View Replies View Related

Writing Own Custom Comparator In Java

Jul 27, 2014

I have a java code that should sort an array of names based on the last name. e.g jane a, jane b, jane z, jane d should be jane a, jane b, jane d, jane z. I have the following code but for some reasons, the s1 in the comparator method is always null.
 
public class ShuffleName {
public static void sortNames(String[] names){
 Arrays.sort( names, new Comparator<String>() {
 public int compare( String s1, String s2 ) { 
String s1last = s1.split("s+")[1];
String s2last = s2.split("s+")[1];
return s1last.compareTo(s2last);

[code]....

View Replies View Related

Reading And Writing Files Into Java?

Apr 17, 2015

have to create a file named Lab13.txt. In the file I have 10 random numbers. I have to import the 10 numbers and have to Multiply all the numbers from Lab13.txt by 10 and save all the new numbers a new file named Lab13_scale.txt. so if the number 10 is in lab13.txt it prints 100 to Lab13_scale.txt. how do i get it to Multiply Here is what I have:

Java Code: import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

[Code].....

View Replies View Related

Writing / Reading To And From Vector In JAVA

Nov 20, 2014

I have a project where I am required to read and write a vector of bank account objects and I am struggling with this concept. I was able to figure it out when the accounts were not stored in a vector but now that I am dealing with vectorsThis is my best attempt. Even though I know it's wrong, what I am trying to do.write/read methods in main:

public static void readTrans()
{
textArea.setText("");
chooseFile(1);
try
{
FileInputStream fis = new FileInputStream(filename);
ObjectInputStream in = new ObjectInputStream(fis);
for (int index=0; index != fileIndex; index++)

[code]....

View Replies View Related

Writing Print All Animals Method In Java

Aug 5, 2014

I am currently working on a java project, this involves me writing some code for a project, below are my attempts at coding so far:


/**
* Prints out details of all animal in the zoo.
*
*/
public void printAllAnimals() {
System.out.println("
Details for all animals in Zoo " + zooId);
System.out.println( "==================================");

[code]....

I currently cannot get the printallanimals() method to work as it should when executing the method printallanimals it just opens a filedialog box, when it is suppose to use the Collection object c,so that animals stored in the zoo can easily be checked.

View Replies View Related

File Handling In Java - Writing Objects In CSV

Dec 20, 2014

I'm doing this assignment in which i have to write some products in csv file...but as u can see in csv file two products are same "Cooking Oil"..so any method that can add two same product's quantity and their amount and write them in file

import java.util.*;
import java.io.*;
public class SalesbyTransactionMonth{
private static final String fileName = "Data.txt";
private static final String fileName1 = "sales_by_trans_month.csv";
String line = "";

[Code] ....

Attached image(s)

View Replies View Related

Writing Gauss Elimination In Java Code

May 2, 2014

I have a big problem with writing Gauss Elimination in Java code. This is my homework, it's true. But I want to learn this, and I don't know how to bite this. I must realise some points:

1) Create new class - Gauss Elimination with two attributes (table A (nxn) and table B with vector (n));

2) Add new method "eliminate" which transform matrix A and parametr vectors B ;

3) Add new method "solve" which calculate inverse substitution.

View Replies View Related

Java Heap Memory Error While Writing Large Data To Excel

Mar 6, 2014

i have to write more than 100000 rows in a excel sheet (file size more than 20 MB) via java.

when i use XSSF, i am getting below Error.

java.lang.OutOfMemoryError: Java heap space
at org.apache.xmlbeans.impl.store.Saver$TextSaver.resize(Saver.java:1592)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.preEmit(Saver.java:1223)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.emit(Saver.java:1144)

[Code]....

when i use HSSF , i am getting the below Error.
java.lang.OutOfMemoryError: Java heap space

I have tried increasing the java heap size , by giving upto -Xms1500m -Xmx2048m

View Replies View Related

Writing Output Of Two Different Java Class Files To One Txt File While Program Runs

Jul 20, 2013

So I am trying to write the output of two different java class files to one txt file while the program runs.  The file name is determined before the program is ran, through the command prompt as arguments.  How can I get the second class file to edit the same txt file without running into compile errors.
 
For right now I'm just going to send everything that the second file outputs to a message String variable, so that the Main class outputs to the the text file.  I still want to learn how to write to the same text file directly from the second class file.
 
import java.io.*;
public class Test{
    public static void main(String[] args) throws IOException{
        int x;
        //create a new file internally called doc.  But externally labelled the user input
        File doc = new File(args[0]);
        if (doc.exists()){

[Code] .....

View Replies View Related

Calculate Percent In Java

Jan 3, 2014

I would like to change the precent from *1.17 (17%) to calc of precent like this :

3% + 5% + 5$

For example :

The resault is 10$ - i want to get :

10$ +3%(0.3$) + 0.5% (0.51$) + 5$ = 15.81$

How i change this line to this calc

if(results[i].getSite()=='Xxx'&&XPrice==0)
{
XPrice =(results[i].getPrice() *1.17);
}
}

View Replies View Related

Military Time - Adding Minutes Displaying Correct Time

Feb 9, 2015

I am working on an assignment that I can't seem to figure out the final part to. The program takes in course data such as the time the class starts and how long it lasts. The time is in military time (0000 - 2400)

I need the output time to be the time the class started, plus the length of the class, and displayed in military time.

for example,

Start Time = 0930
Length = 50 minutes
Endtime = 1020

I can't for the life of me figure out how to do this. I have gotten a program that works for this time and minutes, and displays the correct 1020. But when I change the information to say

Start time: 0700
Length = 90 minutes

I get:

Endtime = 90

90 is technically correct, the way the formula is setup, but I need it to display 0900 not 90.

Here is the code that I have. Be easy, I'm still learning, and this is just the file I created to get the formula to work. Also, the verbose in here is just for my own debugging to make sure values should be what I'm expecting them to be.

public class calc
{
public static void main(String[] args) {
double hours, minutes, length;
double temp;
int time = 2400;
hours = time / 100;
System.out.println("Hours are: " + hours);

[Code] ....

View Replies View Related

Calculate Coupon Discount In Java?

Feb 9, 2015

i finished up a project here and seem to be running into some issues. I figured its my notation, when i ask a user to enter a number, if its below 10, it should *only* print "No Coupon." but what appears to happen is that the program prints "No Coupon" Plus the "discount coupon and % of purchase."

import java.util.Scanner;
public class assign1c { /* Start of Class 1c */
static double cost;
static double coupon = 0;
static String x = "No coupon";
public static void main(String[] args) {
// TODO Auto-generated method stub

[code]...

View Replies View Related







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