Question

programming logic C# visual studio Use an if…else-if…else statement to output the following based on an...

programming logic C# visual studio

  1. Use an if…else-if…else statement to output the following based on an int time entered in military time (ie. 23 == 11:00 p.m., 11 == 11:00 a.m.). You will need to use a ReadLine() and then convert the input to an int value. Based on the input, output the following messages:

Input          Output

0-11            Good Morning
12-16          Good Afternoon

> 16            Good Evening

0 0
Add a comment Improve this question Transcribed image text
Answer #1
using System;

class Program
{
    static void Main()
    {
        Console.Write("Enter time: ");
        int i = Convert.ToInt32(Console.ReadLine());
        if(i<12){
            Console.Write("Good Morning");    
        }
        else if(i<16){
            Console.Write("Good Afternoon");
        }
        else{
            Console.Write("Good Evening");
        }
        
    }
}
Add a comment
Know the answer?
Add Answer to:
programming logic C# visual studio Use an if…else-if…else statement to output the following based on an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming logic C# visual studio. Please paste the code with the screenshot. Compute the average of...

    Programming logic C# visual studio. Please paste the code with the screenshot. Compute the average of the elements of the given array and then output the average. int[] numbers = new int[10]; Add these numbers to the array 87, 68, 94, 100 , 83, 78, 85, 91, 76, 87 The output should be like this: The average is ……

  • Determine the time period of the day in C++ a. Request an hour in military time...

    Determine the time period of the day in C++ a. Request an hour in military time between 0 and 23 inclusive. b. If the value for hour is invalid: 1. Output Invalid hour". 2. Repeat the input request. a. Request the minutes b. Print the time using hh:mm format C. Convert to 12 hour format (i.e. AM/PM) and print Use a single if/else-if/else structure to do the following: 1. If the hour is between 0 and 12 inclusive, output "It...

  • C Programming I was given this code to display the following as the output but it...

    C Programming I was given this code to display the following as the output but it does not seem to work. what is wrong? or can someone guide me through the steps? thanks! I have created the txt file named myfile.txt but the program will not compile. please help. I am forced to use Microsoft visual studio. This program makes a duplicate copy of a file (reads input from a file and write output to another file) 1 #include <stdio.h>...

  • PoD 4: Greetings all around! Instructions Good day! Bonjour! Good evening! Bonsoir! You are in a...

    PoD 4: Greetings all around! Instructions Good day! Bonjour! Good evening! Bonsoir! You are in a bilingual country! A nice thing to know is how to greet people in any language. You are going to write a program to make sure that we know how to greet the peoples around us. The French word "Bonjour" means "Good day. This is greeting can be used from morning until dusk (let's 18:00 or 6pml. After dusk we might say "Bonsoir" or "Good...

  • for python Introduction The purpose of this assignment is to familiarize you with the writing Python...

    for python Introduction The purpose of this assignment is to familiarize you with the writing Python scripts that demonstratest usage GUI programming. Long-Distance Calls A long-distance provider charges the following rates for telephone calls: Rate Category Daytime 6:00 a.m. through 5:59 p.m.) Evening (6:00 p.m. through 11:59 p.m.) Off-Peak (midnight through 5:59 a.m.) Rate per Minute $ 0.07 $ 0.12 $ 0.05 Write a GUI application that allows the user to select a rate category (from a set of radio...

  • To conclude the project, use the UML diagram you created last week and create an application in Visual Studio name...

    To conclude the project, use the UML diagram you created last week and create an application in Visual Studio named School. Once you have written the code, be sure and test it to ensure it works before submitting it. Below is the UML diagram for the basic class we created last week for your reference, but for this project be sure you use the one that you created last week. Good luck and be sure to get started early in...

  • Please use Visual Studio! Let me know if you need anything else <3 #include <stdio.h> #include...

    Please use Visual Studio! Let me know if you need anything else <3 #include <stdio.h> #include <string.h> #pragma warning(disable : 4996) // compiler directive for Visual Studio only // Read before you start: // You are given a partially complete program. Complete the functions in order for this program to work successfully. // All instructions are given above the required functions, please read them and follow them carefully. // You shoud not modify the function return types or parameters. //...

  • THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #inclu...

    THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #include "pch.h" #include #include using namespace std; // Function prototype void displayMessage(void); void totalFees(void); double calculateFees(int); double calculateFees(int bags) {    return bags * 30.0; } void displayMessage(void) {    cout << "This program calculates the total amount of checked bag fees." << endl; } void totalFees() {    double bags = 0;    cout << "Enter the amount of checked bags you have." << endl;    cout <<...

  • please do the program in simple programming it is for my first c++ computer class i...

    please do the program in simple programming it is for my first c++ computer class i posted the example on pic 2,3 which is how this should be done Write a program that calculates and prints the bill for a cellular telephone company. The company offers two types of services: regular and premium. Its rates vary depending on the type of service. The rates are computed as follows: Regular service: $10.00 plus the first 50 minutes are free. Charges for...

  • Hi!, having trouble with this one, In this class we use visual studio, C++ language --------------------------------------------------------------...

    Hi!, having trouble with this one, In this class we use visual studio, C++ language -------------------------------------------------------------- Exercise #10 Pointers - Complete the missing 5 portions of part1 (2 additions) and part2 (3 additions) Part 1 - Using Pointers int largeArray (const int [], int); int largePointer(const int * , int); void fillArray (int * , int howMany); void printArray (const char *,ostream &, const int *, int howMany); const int low = 50; const int high = 90; void main()...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT