# Need help to write these programs.



## GavinVG (Apr 14, 2010)

1. I need to write a program that gets the time of day from the user and outputs the number of seconds since last midnight.

2. Write a program that gets the month of the day from the user and outputs the approximate number of minute since the first of the year.


----------



## Fourstaff (Apr 14, 2010)

In what language? And for what purpose?


----------



## GavinVG (Apr 14, 2010)

Java language and for my school work i dont know how to do.


----------



## Kreij (Apr 14, 2010)

Welcome to TPU 

Post what you have so far and people will be happy to help you find problems with your code.


----------



## GavinVG (Apr 14, 2010)

My teacher said this would help to solve the program your doing.



import java.lang.StringBuffer;
import java.io.IOException;
public class Project6_1 
{
	public static void main(String Args[])
	{
		System.out.println("Please enter one number:");

		String InputString = GetConsoleString();

		int NumberOne = Integer.parseInt(InputString);

		System.out.println("Please enter another number:");

		InputString = GetConsoleString();
		int NumberTwo = Integer.parseInt(InputString);

		try
		{
			int NumberThree = NumberOne / NumberTwo;
			System.out.println("NumberOne divided by numberTwo = " + NumberThree);
		}
			catch(ArithmeticException AE)
			{
		System.err.print("Divide By Zero Exception Thrown");
		}
		catch(Exception E)
		{
			System.err.println("General Exception Thrown");
		}
		System.out.println("Press enter key to continue ");
		GetConsoleString();
	}       // end of main

	// DEFINITION OF GetConsoleSting goes here

	}


----------



## Fourstaff (Apr 14, 2010)

Can't do Java D:, or indeed, any other languages  so you will have to wait for a nice soul to help you out.


----------



## Kreij (Apr 14, 2010)

Basically what you need to do is get the time the user entered and then multiply the hours by the number of seconds in an hour, multiple the minutes by the number of seconds in a minute. and then add them together. You will have to correct for time after 1:00 PM.

So if the user enters 4:10 AM, its (4 * 3600) + (10 * 60)
If 1:30 PM is entered its ((1 + 12) * 3600) + (30 * 60)

The example the teacher gave you shows you how to get user inpput and then do something with it.


----------

