Sharp Tutorial
Clock class to set time am pm mode

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

Week 1

  • Ans of Question 1
  • Ans of Question 2
  • Ans of Question 3
  • Ans of Question 4
  • Ans of Question 5

Week 2

  • Ans of Question 1
  • Ans of Question 2
  • Ans of Question 3
  • Ans of Question 4
  • Ans of Question 5

Week 3

  • Question 1
  • Question 2
  • Question 3
  • Question 4
  • Question 5

Week 4

  • Question 1
  • Question 2
  • Question 3
  • Question 4
  • Question 5

Week 5

  • Question 1
  • Question 2
  • Question 3
  • Question 4
  • Question 5

Solution of java assignment questions

Clock class to set time am/pm mode

class Clock
{
int hours,minutes,seconds;

Clock(int h ,int m, int s)
 {
  hours=h;
  minutes=m;
  seconds=s;
 }
 
 void isTimeValid()
  {
	if(hours>=0 &&  hours <24 && minutes >=0 && minutes<60 && seconds>=0 && seconds <60)
		System.out.println("time is valid");
	else
		System.out.println("time is not valid");
  }
  
  void setAmPmMode()
  {
	if(hours<12)
	{ 
     System.out.println("Time is"+hours+":"+minutes+":"+seconds+" AM");
	}
    else
	{
		hours=hours-12;
		System.out.println("Time is"+hours+":"+minutes+":"+seconds+" PM");
	}
  
	  
  }
  
}
class checkMain
{
	public static void main(String args[])
	{
		
		Clock c1= new Clock(15,34,66);
		c1.isTimeValid();
		c1.setAmPmMode();
		
	}
}
Watch video in full size

Video tutorial

Click To Read: SQL Tutorial With Easy Example Queries.

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial