Java Big Problem

Java Big Problem

View Answers

November 24, 2008 at 11:31 PM

Hi friend,

Code to solve the problem :

import java.io.*;
import java.text.*;

public class MeterReading {
public static double MyRound(int places, double value) {
return Math.round(value*Math.pow(10, places))/Math.pow(10, places);
}
public static void main(String [] args) throws IOException{
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Current Reading");
int currentReading= Integer.parseInt(br.readLine());

System.out.println("Enter Previous Reading");
int previousReading = Integer.parseInt(br.readLine());

double result = 0;
double rate = 0;
int diffReading = currentReading - previousReading;

if(diffReading<=100)
{
rate = 1.25;
}
else if(diffReading>100 && diffReading<=250)
{
rate = 1.50;
}
else if(diffReading>250 && diffReading<=350)
{
rate = 1.80;
}
else if(diffReading>350)
{
rate = 2.20;
}

double bill = diffReading*rate;


System.out.println("Total Bill : " + MyRound(2,bill));


}
catch(Exception e){
System.out.println("Out of range!");
}
}
}

For more information on Java visit to :

http://www.roseindia.net/java/

Thanks

Vineet









Related Tutorials/Questions & Answers:
Java Big Problem - Java Beginners
Java Big Problem  Input the current meter reading and the previous..., Code to solve the problem : import java.io.*; import java.text.*; public... on Java visit to : http://www.roseindia.net/java/ Thanks Vineet
Very Big Problem - Java Beginners
Very Big Problem  Write a 'for' loop to input the current meter reading and the previous meter reading and calculate the electic bill with the following conditions(all must be fulfilled in one class only): (i)if unit(current
Advertisements
Reading big file in Java
Reading big file in Java  How to read a big text file in Java program?   Hi, Read the complete tutorial at How to read big file line by line in java? Thanks
Is Java mandatory for big data?
Is Java mandatory for big data?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Is Java... that I can learn the topic "Is Java mandatory for big data?". Also
The Big Competition - Java Beginners
The Big Competition  Let the Machine understand you ----------------------------- Each team is asked to implement an application that can execute at least 3 commands ? depend on the operating system that you are working
The Big Competition - Java Beginners
The Big Competition  Let the Machine understand you ----------------------------- Each team is asked to implement an application that can execute at least 3 commands ? depend on the operating system that you are working
The Big Competition - Java Beginners
The Big Competition  Let the Machine understand you ----------------------------- Each team is asked to implement an application that can execute at least 3 commands ? depend on the operating system that you are working
The Big Competition - Java Beginners
The Big Competition  Let the Machine understand you ----------------------------- Each team is asked to implement an application that can execute at least 3 commands ? depend on the operating system that you are working
java Big - Java Beginners
java Big  Hi pls observe the following coed: import mysql.DataAcc; // import package class for getting database connection import java.sql.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; class
java program_big digits multiplication..
java program_big digits multiplication..  i want program about big digits multiplication program using java..plz tel me answer
java Problem
java Problem  I want to create a binary tree for displaying members in Downline. i am creating a site for MLM(Multi-Level MArketing). tree must be dynamically populated from database. is there any help for me. Thanks in advance
JAVA Problem
JAVA Problem  Write a program that takes two parameters 1. a word 2. an array of words It should then remove all instances of the word in the array. For Example: INPUT word="ravi" word_array = ["Chethan Bhagat
resolution problem in java
resolution problem in java  I designed project in java in my PC when run the same project in some other PC i can't fully view my java forms.Some said that it is resolution problem
Add two big numbers - Java Beginners
Add two big numbers - Java Beginners  Hi, I am beginner in Java and leaned basic concepts of Java. Now I am trying to find example code for adding big numbers in Java. I need basic Java Beginners example. It should easy
java programming problem - JDBC
java programming problem  Hi, Request you to provide the source code in Java for the following programming problem : upload .csv file data into oracle database. please send the solution to [email protected]
Problem in uploading java application
Problem in uploading java application  I have uploaded my java application (folder created under webapps) using Filezilla FtpClient.Application... this problem
for a problem in coading - Java Beginners
for a problem in coading  what is the problm in following coading...(String[] args) { mywindow (); } }   Hi Friend, There is no problem... mywindows.java Run : java mywindows Thanks RoseIndia Team
Multiplication problem - Java Beginners
Multiplication problem  I am facing a peculiar problem in java regarding a multiplication. Please see below: 19300 * 0.001 = 19.3 19400 * 0.001 = 19.400000000000002 (why is this ??) 19500 * 0.001 = 19.5 Can anybody help
java input problem - Java Beginners
java input problem  I am facing a Java input problem
code problem - Java Beginners
java script j2ee j2me sql plz help me to sort out this problem. thnx  ...code problem  Dear sir, I'm havin a problem that suppose i've got a file that contains the following lines- java java script j2ee php sql
Problem on JAVA Programme
Problem on JAVA Programme  public class AA { int add(int i) { int y = i; y += 20; if (y <= 100){ y +=30;add(y);} System.out.println("Final Value of y : " + y); return y; } public static void main
JAVA CLASSPATH PROBLEM
JAVA CLASSPATH PROBLEM  hi all Friends I am stuck using the java servlets and problem raise for classpath. I had a problem with servlet to call... that it didn't found any java class (which is java class calling from servlet). but i
java programming problem - JDBC
java programming problem  Hi, Request you to provide a solution... problem to the following mail id : Problem : upload excel file data into oracle database using java / j2ee. mail id : [email protected]
Java Problem - Java Beginners
Java Problem  Write a program 2 input a positive integer n and check wheter n is prime or not and also know the position of that number in the prime..., Code to solve the problem : import java.io.*; public class PrimeNumber
How to read big file line by line in java?
Learn how to write a program in java for reading big text file line by line... to read the big file in your java program. For example you have to process some... is very useful in reading big file line by line in Java. In this tutorial we
Java implementation problem
/answers/viewqa/Java-Beginners/28578-java-implementation-problem-.html...Java implementation problem  I want to implement following in java... problem in your post previews. please consider 1. 2. points just after main
code problem - Java Beginners
; Hi friend, Code to help in solving the problem : import java.io.... in Java visit to : http://www.roseindia.net/java/example/java/io/ Thanks
java implementation problem
java implementation problem   I want to implement following in java code : Main thread Create three threads wait for completion of stage 2 of all three threads Access all three local variable (LC0, LC1, LC2) of threads bulid
problem 1 - Java Beginners
problem 1   Hi, please help me!!!! How can i code in java using Two-dimensional Arrays? This question is related to the one i posted before. this is my input data file: 88 90 94 102 111 122 134 75 77 80 86 94 103 113 80
Basic problem for Java experts
Basic problem for Java experts  This assignment will test your knowledge of Arrays Array searching Array sorting Array processing Specification An athletics club require a simple statistical analysis program for analysing lap
code problem - Java Beginners
code problem  Dear sir, I have an excel file in D: drive called today.xls, i want to open it thru java program, what code would be compatible plz help me  Hi friend, Code to help in solving the problem : import
problem with main - Java Beginners
problem with main   import javax.swing.*; import java.awt.... a problem. when i compile it appears this message: java.lang.NoSuchMethodError: main... it with html file. applet.html: Java Applet Demo Thanks
code problem - Java Beginners
code problem  Dear sir, my problem is that I've a string value if this String value has "quit" then output should be "bye". i want to make this program using SWITCH CASE statement. how to implement String value in Switch plz
Bid Problem - Java Beginners
in this application explain in details : Code to help in solving the problem...!"); } } } For more information on Java visit to : http://www.roseindia.net/java/ Thanks
Problem with code - Java Beginners
Problem with code  Hi Deepak. Im a newbie here at your forum. I have got a simple code of mine which is having a little problem. When I compile it, i get an...,identifier expected'...error. Could you help me out? Thank you
Problem in coding - Java Beginners
Problem in coding  How many times do you have to roll a pair of dice before they come up snake eyes? You could do the experiment by rolling the dice... friend, Code to help in solving the problem. public class Stimulates
problem - Java Beginners
in java if want something like this using array?   Hi friend, Code to solve the problem : import java.io.*; public class JavaMeanDeviation
problem - Java Beginners
in java if want something like this using array?   Hi friend, Code to solve the problem : import java.io.*; public class JavaMeanDeviation
code problem - Java Beginners
code problem  Dear sir, My problem is that i have some string value and in some case i want to remove all the value of this string, i tried this code- Response.str.clear(); but it shows some error called "response package
coding problem - Java Beginners
coding problem  i had a big doubt. public ArrayList readExpenseType() throws ClassNotFoundException, SQLException,Exception { DBConnection dbc = new DBConnection(); Connection con = dbc.getConnection(); ArrayList
code problem - Java Beginners
code problem  Dear sir, my problem is given below: suppose a file Carries the following lines- Name: john age: 45 Address: goa phone...; Hi friend, Code to help in solving the problem : import java.io.
Problem with picture - Java Beginners
Problem with picture   Hi, I Develope a School Automated System that takes a details from the user interface and deposited into the database (MSSQL), i make the registrar to be able to upload the student picture from
Problem with picture - Java Beginners
Problem with picture   Hi, I Develope a School Automated System that takes a details from the user interface and deposited into the database (MSSQL), i make the registrar to be able to upload the student picture from
code problem - Java Beginners
your problem in details. Which keyword search the line. Thanks
Problem in java 1.6 - Java Beginners
Problem in java 1.6  Am facing problem in java 1.6 . Ex. In a Frame......  Hi friend, Give source code where you having the problem For read more information on java visit to : http://www.roseindia.net/java
code problem - Java Beginners
of program. thnx  Hi friend, Code to help in solving the problem
arraylist problem - Java Beginners
arraylist problem  Hello.... I wrote the following code for adding a string array into an array list along with other strings... and to display the string array... But there's a problem with this... import java.util.
code problem - Java Beginners
code problem  Dear sir, I've some string called "JohnSon" that has to be crypted first and then decrypted, how to crypt and decrypt data plz tell me.  Hi friend, Code to help in solving the problem : public
code problem - Java Beginners
code problem  Dear sir, my problem is that, i have two Combobox one carries the followin value- "india","america". whereas another carries - "mumbai","dellhi","washingtone","newyork". when india is selected from one combobox
Java problem - Java Beginners
Java problem  what are threads in java. what are there usage. a simple thread program in java  Hi Friend, Please visit the following link: http://www.roseindia.net/java/thread/index.shtml Thanks

Ads