Question

In: Computer Science

Write a program that accepts a number of minutes and converts it both to hours and...

Write a program that accepts a number of minutes and converts it both to hours and days. For example, 6000 minutes is 100.0 hours or 4.166666666666667 days.

(I currently have what is below)

import java.util.Scanner;
public class MinutesConversion {
    public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
           int numOfMinutes = sc.nextInt();
            double hour = numOfMinutes/60.00;
            double days = (hour/24);

            System.out.println(numOfMinutes + " minutes is " + hour + " hours or " + days + " days.");
        }
    }

The test values are 6000 and 1578. My program gets the correct answer for 6000 but not 1578? Any advice?

Solutions

Expert Solution

import java.util.Scanner;
public class MinutesConversion{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int numOfMinutes = sc.nextInt();
double hour = numOfMinutes/60.00;//converting to hours //since each hour has 60 mins
double days = (hour/24);//converting to days//since ecah day has 24 hrs
//the logic is fine
//and it is giving correct output for 1578 also
System.out.println(numOfMinutes + " minutes is " + hour + " hours or " + days + " days.");
}
}

output:


Related Solutions

Write a program that accepts a number of minutes and converts it to days and hours....
Write a program that accepts a number of minutes and converts it to days and hours. For example, 6000 minutes represents 4 days and 4 hours. Be sure to provide proper exception handling for non-numeric values and for negative values. Save the file as  MinuteConversionWithExceptionHandling.java
3. Write a java method that accepts a binary number and converts it to decimal then...
3. Write a java method that accepts a binary number and converts it to decimal then display the result. For Example: (110)2 = (6)10 (2 2 *1)+ (21 *1) + (20*0) = 6 Additional task: write a method that accepts a decimal and converts it to binary. i need to solve it as soon as and i will upvote you directly
Write a program that converts the user's number into the desired unit of measurement. The user...
Write a program that converts the user's number into the desired unit of measurement. The user will pick the desired unit from a menu shown below. Ask the follow-up question (the number to convert) and do the math ONLY if the user picks a valid choice from the menu. You can see the conversions / multipliers needed for this program in the output section below. Menu/Prompt: Enter the number that corresponds to your desired unit conversion from the choices below:...
2. Write a program that asks for hexadecimal number and converts it to decimal. Then change...
2. Write a program that asks for hexadecimal number and converts it to decimal. Then change it to convert an octal number to decimal in perl language.
Write a program in C++ that converts a positive integer into the Roman number system. The...
Write a program in C++ that converts a positive integer into the Roman number system. The Roman number system has digits I      1 V    5 X    10 L     50 C     100 D    500 M    1,000 Numbers are formed according to the following rules. (1) Only numbers up to 3,999 are represented. (2) As in the decimal system, the thousands, hundreds, tens, and ones are expressed separately. (3) The numbers 1 to 9 are expressed as...
Write a program in C++ that converts a positive integer into the Roman number system. The...
Write a program in C++ that converts a positive integer into the Roman number system. The Roman number system has digits I      1 V    5 X    10 L     50 C     100 D    500 M    1,000 Numbers are formed according to the following rules. (1) Only numbers up to 3,999 are represented. (2) As in the decimal system, the thousands, hundreds, tens, and ones are expressed separately. (3) The numbers 1 to 9 are expressed as...
A C program that accepts a single command line argument and converts it in to binary...
A C program that accepts a single command line argument and converts it in to binary with array length of 16 bits. The array should contain the binary of the int argument. the program should also convert negative numbers. Side note the command line arg is a valid signed int.
Write a program that request a time interval in seconds and display it in hours, minutes,...
Write a program that request a time interval in seconds and display it in hours, minutes, second format. (java)
In a program, write a function that accepts two arguments: a list, and a number n....
In a program, write a function that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all of the numbers in the list that are greater than the number n. The program should ask for a list of numbers from the user as well as a value (a, b, c)--> inputs from user. After that, each number in that list should be compared to that value (a or b or...
Write a python program that will take in the number of call minutes used. Your program...
Write a python program that will take in the number of call minutes used. Your program will calculate the amount of charge for the first 200 minutes with a rate of $0.25; the remaining minutes with a rate of $0.35. The tax amount is calculated as 13% on top of the total. The customer could have a credit that also has to be considered in the calculation process. Finally, the program displays all this information. Below is a sample run:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT