Show Amount Of Number According To Its Interval
Jul 4, 2014
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;
[Code] .....
View Replies
ADVERTISEMENT
Oct 9, 2014
import java.util.Scanner;
public class LM6Assignment
{
public static void main(String[] args)
{
Scanner inputDevice = new Scanner(System.in);
int numBooks = 0;
double onePhotoBook = 10.99;//each book cost 10.99
double costof1Book;
//mehtod calls
costof1Book = computeBill(onePhotoBook);
[Code] ....
How to code it so I can put in how many books they need and for it to show up with the amount for multiple photo books..
View Replies
View Related
May 3, 2015
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();
[Code] .....
View Replies
View Related
Jun 9, 2014
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;
}
}
View Replies
View Related
Apr 7, 2014
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:
"org.apache.jasper.JasperException: java.lang.NumberFormatException: null"
(I've attached a screen shot of the error) : NumberFormatException.bmp (750.98K)
What does this mean? how do i find the line in the code that has the error?
View Replies
View Related
Jan 13, 2014
I've been trying to find the easiest way to write to generate a number which is between intervals of a arbitrary min and a max value.I've been searching for this but I don't find this particular thing.I've found that this combination works:
Java Code: int guess = rand.nextInt(max - (min - 1)) + min; mh_sh_highlight_all('java');
But I wonder, is this really the easiest way of writing it?
View Replies
View Related
Aug 9, 2014
public Map<Integer , String> Timeinterval(int value) {
int i = 1440/value ;
Map<Integer, String> timeInt = new HashMap<Integer, String>() ;
DateTimeFormatter formatter = null ;
for(int a=0 ; a< i ; a++) {
[Code] .....
The argument value gets it value from jsp at rumtime
The moment the control reaches at :- formatter = DateTimeFormat.forPattern("HH:mm");
it could not go beyond this . I executed this part
DateTimeFormat.forPattern("HH:mm"); by pressing cntrl+shift+I
and got this message :- could not resolve type: org.joda.time.format.DateTimeFormat
Basically what I want to do is increment time for eg: if time is 09:00 and I want to increment it by 30 then it should become 09:30 and this goes on till the time loop condition is satisfied, when i researched on net, I found out that Joda library is easirer to work with for such tasks.
View Replies
View Related
Sep 7, 2014
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.
View Replies
View Related
Jan 3, 2015
My code compiles and runs just fine, i'd just like to get creating a small square box that shows number of words used next to the "word count = ". i'd wanto to press the count words button to count and show the number in the square box. here is my code.
import javax.swing.*;
import javax.swing.text.*;
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class wordCount extends JFrame implements ActionListener
[Code] .....
View Replies
View Related
Mar 28, 2014
I cannot get the right output for my program. I need to get the total number of pennies in dollar amount for the output of Total Pay. This is my program. The directions are:
Write a program that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies. Do not accept a number less than 1 for the number of days worked.
import java.util.Scanner;
import java.text.DecimalFormat;
public class PenniesForPay {
public static void main(String[] args) {
int numDays;
[Code] ....
totalSalary should be total number of pennies / 100....However its not picking up only day 30 of pennies which is 536,870,912 pennies and then dividing it?
View Replies
View Related
Apr 30, 2015
I have the following code.
class A {
List<StringBuilder> list;
public void output(List<StringBuilder> objectToOutput){
try(BufferedWriter bw = new BufferedWriter(new FileWriter("temp.txt"))){
for(StringBuilder row:objectToOutput) bw.write(row.toString());
}catch(IOException e){}
[code]....
Why don't the a's show up on the console? I put them in as part of the debugging process and now I don't understand why they don't show up in both places.
View Replies
View Related
Mar 11, 2014
How do i make the 'date' column show only the date and 'timeIn' and 'timeOut' column only show the time. In my database table my 'date' column is a date type and 'timeIn' and 'timeOut' column is time.
View Replies
View Related
Mar 14, 2014
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?");
[Code] ....
View Replies
View Related
Apr 30, 2014
i want to display a amount in indian currency format,
i.e=10000000=this iwant show is=1,00,00,000 rather than 10,000,000
View Replies
View Related
Jun 14, 2014
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.
[code]...
View Replies
View Related
Apr 10, 2015
How to calculate the qty and price and total of the amount in total column.
View Replies
View Related
Oct 27, 2014
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++)
[Code]...
View Replies
View Related
Mar 24, 2014
i have this code
////////////////////////////////////////////
<form name="myform" action="http://localhost:8080/EASYPAY.COM/faces/newxhtml.xhtml"method="post">
amount
<input type="text" name="amount"value="">
<input type="submit" >
</form>
[code]...
when i submit the html form the value of amount does not appear in the second jsf page new.xhtml what might be the problem
View Replies
View Related
Sep 18, 2014
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
View Replies
View Related
Sep 18, 2014
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...
View Replies
View Related
Sep 18, 2014
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
View Replies
View Related
Jan 29, 2015
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");
[code]....
View Replies
View Related
May 3, 2014
Here is what I'm trying to do using arrays.
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) {
[Code] .....
View Replies
View Related
Oct 10, 2014
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
Java Code:
for (int xpos = 10; xpos < getWidth() - 40; xpos += getWidth() / 8) {
drawTree(150, 200, xpos, getHeight() / 2.0 - 50);
historyT.add(trunk);
historyL.add(leave);
} mh_sh_highlight_all('java');
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.
View Replies
View Related
Feb 14, 2014
This method accepts 1 integer, amount (the amount of money). Output the minimum number of in quarters, dimes, nickels and pennies used to make up the amount. For example, an amount of 32 would require 1 quarter, 1 nickel and 2 pennies.
This is the question^
My codes are:
public static int change (int amount) {
int quarters = amount / 25 ;
int firstresult = amount % 25 ;
return quarters ;
int nickel = firstresult / 5 ;
[Code] .....
The codes were working when i used System.out.println instead of return, but our teacher required us to use return (functions).
I get the compile error: Unreachable statement.
View Replies
View Related
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