Ron Singh
Java Big Problem
1 Answer(s)      8 years ago
Posted in : Java Beginners

Ads

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
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
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 program_big digits multiplication..
java program_big digits multiplication..  i want program about big digits multiplication program using java..plz tel me answer
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
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
My big doubt on java prgmn.. need solution asap
My big doubt on java prgmn.. need solution asap  How do you write prgrm 4 dis : 3% discount is given if payment is made within 30days of purchase. date of purchase and payment entered by user
big doubt
;html> <body> <%@page language="java" import="java.sql.*"%> <%@page language="java" import="java.io.*"%> <
Certificate in Big Data Analytics
Certificate in Big Data Analytics  Hi, Which are the Certificate in Big Data Analytics? What all certificates I should earn to get GOOD JOB in Big Data technologies. I have heard from my friend about Big Data and he is saying
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
Reading a big file effeciently
Reading a big file effeciently  How to read a large text file quickly without memory error in Java? What is the best method to read a big file very efficiently? Thanks   Hi, Kindly check the program Java Read File
Big Data Analytics with Hadoop
Big Data Analytics with Hadoop  Hi, How Big Data Analysis is done? How one can use Hadoop for Big Data Analytics? Thanks
Hadoop for Big Data
Hadoop for Big Data  Hi, How Hadoop is important in Big Data? Why developers are learning Hadoop first and other technologies after that? Thanks
IBM Big data capabilities
IBM Big data capabilities  What are the capabilities of the IBM Big data System?   IBM Big Data Management system provides unlimited capabilities: Here is the brief of the IBM Big Data Management System: Data
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
Best way to learn Big Data
Best way to learn Big Data  Hi, I am beginner in Big Data, but I am an experienced Java programmer. I have worked on many enterprise projects. I have good understanding of Java Language and most of the frameworks of Java. I have
Big Data and Hadoop Training - Online and class room
Big Data and Hadoop online training for Java Programmer Yes, you have reached at right place to learn Big Data and Hadoop in quickest possible time. We at Rose India provides online training to experienced Java
java input problem - Java Beginners
java input problem  I am facing a Java input problem
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 raichallp@yahoo.in
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
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
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
Big Data tools - Hadoop - Why Hadoop as Big Data tool?
Big Data tools - Hadoop - Why Hadoop as Big Data tool?  Hi, How we can say that Hadoop is a Big Data Tool? What are the benefits of Hadoop in Big Data Environment? Thanks
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
JavaScript method big()
JavaScript method big()       This section illustrates you the use of JavaScript method big(). The big() method allows you to display the specified string in a big font. You can see