Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- class Main {
- /*reads and returns a double from the keyboard*/
- public static double readDouble(String prompt){
- System.out.println(prompt);
- java.util.Scanner keyboard = new java.util.Scanner(System.in);
- return keyboard.nextDouble();
- }
- /*bmiCalc method takes double height and double weight as parameters,
- calculates the BMI using the formula above ( bmi = weight/(height * height) ) and returns the bmi as a double.*/
- public static double b2mb(double b){
- //Your code here
- double b2mb = b/1000000;
- return b2mb;
- }
- /*main method that calls readDouble twice to ask you your height and weight,
- passes the values to bmiCalc, and prints out the returned double value of bmi.*/
- public static void main(String[] args) {
- //Your code here
- DecimalFormat df = new DecimalFormat("#,###,##0.00");
- double bite = readDouble ("How many bytes do you want to convert to Megabytes?");
- double b2mb = b2mb(bite);
- System.out.println(bite + " bytes is " + df.format(b2mb) + " Megabytes");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement