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
rusak2 [61]
3 years ago
8

Something is wrong with the logic in the program above. For which values of time will the greeting "Good Morning!" be displayed?

var time = promptNum("What hour is it (on a 24 hour clock)?"); var greeting = ""; if (time < 6) { greeting = "It is too early!"; } else if (time < 20) { greeting = "Good Day!"; } else if (time < 10) { greeting = "Good Morning!"; } else { greeting = "Good Evening!"; } console.log(greeting);
Computers and Technology
1 answer:
Klio2033 [76]3 years ago
7 0

Answer:

There is logic problem in condition of elseif statement that is (time<20).

Explanation:

elseif(time<20) will be true for time<10 that means program will never greet good morning as to make logic correct either change condition from <em>elseif(time<20)</em> to <em>elseif(time<20&& time>=10)</em>. Or change the order of condition like check first for <em>elseif(time<10) </em>

solution 1

if (time < 6) { greeting = "It is too early!"; }

else if (time < 20 && time>=10) { greeting = "Good Day!"; }

else if (time < 10) { greeting = "Good Morning!"; }

else { greeting = "Good Evening!"; }

console.log(greeting);

solution 2

if (time < 6) { greeting = "It is too early!"; }

else if (time < 10) { greeting = "Good Morning!"; }

else if (time < 20 ) { greeting = "Good Day!"; }

else { greeting = "Good Evening!"; }

console.log(greeting);

You might be interested in
Rocks created from compaction and cementation of sediments are called:
Effectus [21]

Answer:

Sedimentary Rocks

Explanation:

Sedimentary rocks are essentially the Frankenstein monsters of the rock world. They're made up of pieces of igneous and metamorphic rocks, sand, clay, and other sedimentary rocks.

4 0
2 years ago
Hey, Another question. I'm sure it's possible in the future, but I wanted to ask if HIE would be possible. I'm sure it would be,
dolphi86 [110]

Answer:

Originally Answered: Will there ever be a band as big as the Beatles? No, there will never be a band as popular as the Beatles. For one thing they were exceptionally good in a time of great music in general.

Explanation:

please mark this answer as brainliest

7 0
3 years ago
Which software would you use to create a print design?
Contact [7]

Audacity and Reaper are audio software programs.

Dreamweaver is for websites.


Illustrator is used for printing brochures, cards etc.


The answer would be A. Illustrator.

7 0
3 years ago
Read 2 more answers
What is the FICO system?
Serhud [2]
It is C) A credit investment system.
8 0
3 years ago
How do you start using the Internet?
fgiga [73]

Answer:

it's

D. open web browser

3 0
2 years ago
Read 2 more answers
Other questions:
  • A compound document contains _______ from different applications.
    12·2 answers
  • In gaming, "rendering" refers to:
    12·2 answers
  • What can search the Internet and select elements based on important words?
    6·2 answers
  • Where is line-of-sight Internet common?<br> In space<br> Outdoors<br> Inside<br> In businesses
    5·1 answer
  • In learning information security, it is important to understand that threats to your company's information assets are present 24
    13·1 answer
  • Explain what led to the invention of lasers
    7·1 answer
  • Read integers from input and store each integer into a vector until -1 is read. Do not store -1 into the vector. Then, output al
    11·1 answer
  • Anyone wanna join my giggl?
    11·2 answers
  • Write a Python program (rainfall.py) to collect data and calculate the average rainfall over a period of years. The program shou
    11·1 answer
  • How is information processed within a<br> motherboard between the hard drive, CPU and RAM,
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!