Question: Java Big Problem

Ads

 
 
 

Share on Google+Share on Google+

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

Ads









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
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
big doubt
;html> <body> <[email protected] language="java" import="java.sql.*"%> <[email protected] 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
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
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
Big Data and its uses
Big Data and its uses  Hi, I am trying to understand the Big Data and its uses. Please tell me: What is Big Data? What is the uses of Big Data? Thanks   Hi, Let me explain you all these things to you. What is Big
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
java input problem - Java Beginners
java input problem  I am facing a Java input problem
What is big data science?
What is big data science?  Hi, What is big data science? What are the technologies to learn in Big Data? Thanks   Hi, Big Data science... of Huge Set of data (know as Big Data). It involves setting up of 100s or even
Big Data and business intelligence
Big Data and business intelligence  Hi, I have Big Data and business... Big Data? Which technologies can be used for Big Data and business intelligence? Thanks   Hi, Let me try to give answer to your Big Data and business
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]
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
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
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
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
How big is 1ZB?
How big is 1ZB?  Hi, How big is 1ZB? Thanks   Hi, 1 Zettabyte [ZB] is equals to 1 073 741 824 Terabyte [TB] 1 Zettabyte [ZB] = 1 073 741 824 Terabyte [TB] Thanks
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
Tutorials   
Java Spring Hibernate Struts Training What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile? How to create first Java Program? Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly?

Ads

 
Advertisement null

Ads