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...
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.
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 C++ program that accepts a positive integer number from the keyboard . The purpose...
Write a C++ program that accepts a positive integer number from the keyboard . The purpose of the program is to find and the display all the square pair numbers between 1 and that number. The user should be able to repeat the process until he/she enters n or N in order to terminate the process and the program. Square numbers are certain pairs of numbers when added together gives a square number and when subtracted also gives a square...
Write a program that converts a given floating point binary number with a 24-bit normalized mantissa...
Write a program that converts a given floating point binary number with a 24-bit normalized mantissa and an 8-bit exponent to its decimal (i.e. base 10) equivalent. For the mantissa, use the representation that has a hidden bit, and for the exponent use a bias of 127 instead of a sign bit. Of course, you need to take care of negative numbers in the mantissa also. Use your program to answer the following questions: (a) Mantissa: 11110010 11000101 01101010, exponent:...
c ++ program that converts from any base to a decimal number
c ++ program that converts from any base to a decimal number
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT