1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GrogVix [38]
3 years ago
6

Write a method string gettimename (int hours, int minutes) that returns the english name for a point in time, such as "ten minut

es past two", "half past three", "a quarter to four", or "five o'clock". assume that hours is between 1 and 12.
English
2 answers:
3241004551 [841]3 years ago
6 0

Answer:

// Program is written in Java Programming Language

// Comments are used for explanatory purpose

// Program starts here

public static String getTimeName(int hours, int minutes) {

// Check for valid time

if ((hours >= 1 && hours <= 12) && (minutes >= 0 && minutes <= 59)) {

// Create an array to hold valid minutes in English

String validminutes[] = {

"", "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" };

String validtime;

// Start Conversion

if (hours == 12){ // Set time to be One

validtime = validminutes[1];}

else{ // Set time to be ahead by one hour

validtime = validminutes[hours + 1]; }

// Check for minutes

if (minutes == 0){ // Replace 0 with O' Clock

System.out.println(validminutes[hours] + "O' Clock");}

else if (minutes == 15){// Replace with quarter past

System.out.println("Quarter past " + validminutes[hours]);}

else if (minutes == 30){// Replace with half past

System.out.println("Half past" + validminutes[hours]);}

else if (minutes == 45){// Replace with quarter to

System.out.println("Quarter to" + a);}

else if (minutes < 30){ // for other minutes between 1-29

System.out.println(validminutes[minutes] + " " + "past" + validminutes[hours]);}

else{ // Other minutes

System.out.println(hour_mint[60 - minutes] + " " + "to " +validtime);}

}

// End of Valid Time

else { // Invalid Tine

System.out.println("Time not valid ");

}

}

// End of Program

artcher [175]3 years ago
4 0
Hi!!

Hope I understood your question...

Ten minutes past two = two ten
half past three = three thirty
a quarter to four = four forty-five
Five o'clock = five

then you can add a.m or p.m.

Hope I helped !!

You might be interested in
Reread lines 97–108. What metaphor does Soto use to explain how he feels as he begins the second half of his workday? What is th
Alex17521 [72]

Answer:

"boredom was a terror almost as awful as the work itself"

- he has the choice to be bored at home or bored at work making money

-the impact: soto is feeling depressed because he no longer sees the hope in working

-he was hoping for money for new clothes

-the work was so hard and overcoming that he lost his drive for his desire

Explanation:

5 0
3 years ago
What is the connection between the innateness hypothesis and the idea of a universal grammar?
love history [14]

In linguistics, the Innateness Hypothesis is the claim that all children have, by virtue of a common biology, a 'Universal Grammar' that defines a space of possible human languages

3 0
3 years ago
You are writing an informative essay on your favorite subject in school. Which sentence would make the BEST concluding
kozerog [31]

Answer:

D

Explanation:

8 0
3 years ago
What is the author of the "Equal Pay Bill" letter trying to persuade his<br> audience to think?
tigry1 [53]

Answer:

Women should not be paid as much as men

Explanation:

4 0
3 years ago
Some of you might not have those advantages. Maybe you
jarptica [38.1K]
There is no excuse for not trying despite the circumstances you might be facing in your life
4 0
3 years ago
Read 2 more answers
Other questions:
  • Why does Shakespeare not tell us what started the family feud? Answer in complete sentences.
    13·1 answer
  • In paragraph 17, what is the meaning of vicissitudes
    7·1 answer
  • How do you say apprentice in Japanese
    10·2 answers
  • Which sentence is written correctly?
    11·2 answers
  • There was a flash of nearby lightning, and soon large drops of rain splashed onto his jeans. He stood to go upstairs, thought of
    7·2 answers
  • Can someone please look at the picture and help me!!
    5·2 answers
  • How had Binya got the blue umbrella?
    9·1 answer
  • Correct the following fragment by adding an Independent clause.
    5·1 answer
  • My future self me now and me and 10 years essay
    14·1 answer
  • What did Papa's words, "Do you want to be like this always?" mean?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!