Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java Big Problem
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Ron Singh
Java Big Problem
1 Answer(s)      5 years and 11 months ago
Posted in : Java Beginners



Advertisement
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.*"%> <
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
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
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
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
Why Big Data is important for Enterprises?
of the customers. Problem of Huge Data There is big issue of managing and analyzing... issue Data storage and retrieval is also a big problem Licensing cost...Why Enterprises are looking for Big Data? What are the importance of Big Data
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
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 problem - Java Beginners
Java problem  I have an image in my application and I need to restrict the image path view on the browser. Noone should be able to right click and see the image path. Please help
java problem - Java Beginners
java problem  Write a program to model a simple calculator. Each data... to power of right operand) q quit Your calculator should display the accumulator... is 0.23999999999999985 + 10 Result so far is 10.24 q 0 Final result is 10.24 
Java Problem - Java Beginners
Java Problem  How to create executable file of a java program.That is steps to create a Jar File of a Java Program  Hi Friend, Try the following code: import java.io.*; import java.util.jar.*; public class
java problem - Java Beginners
java problem  Suppose list is an array of five components of the type int.What is stored in list after the following Java code executes? for (i = 0; i < 5; i++) { list[i] = 2 * i + 5; if (i % 2 == 0) list[i] = list[i
 

 

 

DMCA.com