0% found this document useful (0 votes)
24 views3 pages

Class 11 Assignment 15 (Prac)

The document contains a Java program that accepts two integers as input - the first between 1-12 representing an hour, and the second between 0-59 representing minutes. It then prints the time in both digital and word formats, handling cases such as quarter past/to, half past, and minutes before/after the next hour. The program contains if/else statements to check the input values and print the corresponding time representation. Some sample runs of the program are included at the end.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Class 11 Assignment 15 (Prac)

The document contains a Java program that accepts two integers as input - the first between 1-12 representing an hour, and the second between 0-59 representing minutes. It then prints the time in both digital and word formats, handling cases such as quarter past/to, half past, and minutes before/after the next hour. The program contains if/else statements to check the input values and print the corresponding time representation. Some sample runs of the program are included at the end.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Class XI A/B/C Computer Science Practical Questions

Assignment 15
Write it in your practical notebook with algorithm and variable description

Question 15 : 28/09/23

/*Write a program to accept two integers, the first integer should be between 1 and 12 (both
inclusive) and second should be between 0 and 59(both inclusive)
* print the accepted integer in time format and also in words*/
import java.util.*;
class Time_Analysis
{
public static void main(String args[])
{
Scanner in =new Scanner(System.in);
int m,n;
System.out.println("ËNTER TWO INTEGERS");
m=in.nextInt();
n=in.nextInt();
if(m<1||m>12||n<0||n>59)
{
System.out.println("INVALID INTEGERS INPUT");
}
else
{
String
hourname[]={"","ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE","TEN","ELEVE
N","TWELVE"};
String
minname[]={"","ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE","TEN","ELEVEN
","TWELVE","THIRTEEN","FOURTEEN","FIFTEEN","SIXTEEN","SEVENTEEN","EIGHTEEN","NINETEEN","
TWENTY","TWENTY ONE","TWENTY TWO","TWENTY THREE","TWENTY FOUR","TWENTY
FIVE","TWENTY SIX","TWENTY SEVEN","TWENTY EIGHT","TWENTY NINE","THIRTY"};
if(n==0)
{
System.out.println("TIME ="+m+":"+"00");
System.out.println(hourname[m]+" O'clock");
}
else if(n<30&&n!=15&&n>9)
{
System.out.println("TIME ="+m+":"+n);
System.out.println(minname[n]+" MINUTES PASSED "+hourname[m]);
}
else if(n>30&&n!=45)
{
if(m==12)
{
System.out.println("TIME ="+m+":"+n);
System.out.println(minname[60-n]+" MINUTES TO "+hourname[1]);
}
else
{
System.out.println("TIME ="+m+":"+n);
System.out.println(minname[60-n]+" MINUTES TO "+hourname[m+1]);
}
}
else if(n==15)
{
System.out.println("TIME ="+m+":"+n);
System.out.println("QUARTER PASSED "+hourname[m]);
}
else if(n==30)
{
System.out.println("TIME ="+m+":"+n);
System.out.println("HALF PASSED "+hourname[m]);
}
else if(n==45)
{
if(m==12)
{
System.out.println("TIME ="+m+":"+n);
System.out.println("QUATER TO "+hourname[1]);
}
else
{
System.out.println("TIME ="+m+":"+n);
System.out.println("QUARTER TO "+hourname[m+1]);
}
}
else
{
System.out.println("TIME ="+m+":"+"0"+n);
System.out.println(minname[n]+" MINUTES PASSED "+hourname[m]);
}
}
}
}
/*ËNTER TWO INTEGERS
7
15
TIME =7:15
QUARTER PAST SEVEN

ËNTER TWO INTEGERS


7
30
TIME =7:30
HALF PAST SEVEN

ËNTER TWO INTEGERS


7
42
TIME =7:42
EIGHTEEN MINUTES TO EIGHT

ËNTER TWO INTEGERS


7
45
TIME =7:45
QUARTER TO EIGHT

ËNTER TWO INTEGERS


7
59
TIME =7:59
ONE MINUTES TO EIGHT

ËNTER TWO INTEGERS


7
24
TIME =7:24
TWENTY FOUR MINUTES PAST SEVEN

*/

You might also like