In this BlueJ program, user will enter time in a specific format like 6,35 or 6,34 where the last two digits represents minutes and the remaining is hour. The program will show the output for the first sample time like 25 Minutes to go to seven.
Here is the BlueJ program on Time
import java.io.*;
class Arr
{
int hr,min;
String str,str1;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public void show() throws IOException
{
int rev;
System.out.print("Enter the Time as 6,45: ");
str=br.readLine();
rev=str.indexOf(',');
hr=Integer.parseInt(str.substring(0,rev));
min=Integer.parseInt(str.substring(rev+1));
min=60-min;
str1=String.valueOf(min);
hr=hr+1;
if(str1.charAt(0)!='1')
{
switch(str1.charAt(0))
{
case '2':
System.out.print("Twenty ");
break;
case '3':
System.out.print("Thirty ");
break;
case '4':
System.out.print("Fourty ");
break;
case '5':
System.out.print("Fifty ");
break;
}
switch(str1.charAt(1))
{
case '1':
System.out.print(" One ");
break;
case '2':
System.out.print("Two ");
break;
case '3':
System.out.print("Three ");
break;
case '4':
System.out.print("Four ");
break;
case '5':
System.out.print("Five ");
break;
case '6':
System.out.print("Six ");
break;
case '7':
System.out.print("Seven ");
break;
case '8':
System.out.print("Eight ");
break;
case '9':
System.out.print("Nine ");
break;
}
System.out.print(" Minutes to go to ");
}
else
{
switch(str1.charAt(1))
{
case '1':
System.out.print(" Eleven ");
break;
case '2':
System.out.print("Twelve ");
break;
case '3':
System.out.print("Thirteen ");
break;
case '4':
System.out.print("Fourteen ");
break;
case '5':
System.out.print("Fifteen ");
break;
case '6':
System.out.print("Sixteen ");
break;
case '7':
System.out.print("Seventeen ");
break;
case '8':
System.out.print("Eighteen ");
break;
case '9':
System.out.print("Nineteen ");
break;
}
System.out.print(" Minutes to go to ");
}
switch(hr)
{
case 1:
System.out.print(" One ");
break;
case 2:
System.out.print("Two ");
break;
case 3:
System.out.print("Three ");
break;
case 4:
System.out.print("Four ");
break;
case 5:
System.out.print("Five ");
break;
case 6:
System.out.print("Six ");
break;
case 7:
System.out.print("Seven ");
break;
case 8:
System.out.print("Eight ");
break;
case 9:
System.out.print("Nine ");
break;
}
}
}
Related Post: BlueJ Programs on Number
Are patterns very important for icse?
ReplyDeleteI think pattern programs are very important for ICSE exam but these type of programs are very much essential for refreshing logic.
Deletesir if i doesnot show my output properly to the external how much marks should i get?????
DeleteIt depends on ISC norms but marks will be deducted.
Delete