Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I NEED THIS IN C# PLEASE Unit Outcomes: Formulate the types of conditionals available to programmers. Generalize the types of conditionals. Write a simple program

I NEED THIS IN C# PLEASE

Unit Outcomes:

Formulate the types of conditionals available to programmers.

Generalize the types of conditionals.

Write a simple program using each type of conditional.

Course Outcome:

Create fundamental programs using concepts such as decision statements and iteration.

Purpose

The purpose of this assignment is to provide the student an opportunity to demonstrate knowledge of the various decision structures such as the if, else if, and switch statements.

Assignment Instructions

You will complete a program to demonstrate the skills presented in this lesson for your selected language path. Please keep in mind that with all the assignments in this course, any given scenarios are hypothetical and intended solely to demonstrate specific skills.

Assignment Requirements

Note: If your language of choice is Web Development, you will need to complete the exercises in both PHP and JavaScript.

Using the language in which you have chosen to focus: C#, Java, web development languages (PHP and JavaScript), please complete the following Assignment:

The program for this assignment will consist of four sections, each headed by the three-line comment below:

//*********************************************************

//****Assignment 2 Section X

//*********************************************************

(where X stands for the portion of the assignment to follow)

Section 1:

Enter the comment with the section title.

Request the user to enter two whole numbers and store those whole numbers in two appropriately defined variables.

Using separate and independent IF statements, compare the two whole numbers with each of the following comparison operators. ==, !=, <, >, <=, >=

Each IF statement that proves true should print to the console the numbers compared and the comparison made. e.g., 5 > = 2

Hint: If the user enters the numbers 5 and 2 then the expected output would be:

5 <> 2

5 > 2

5 >= 2

Section 2:

Enter the comment with the section title.

Request the user to enter a grade.

Using an if statement with an else clause, compare the user input with the number 60.

If the grade entered is greater than or equal to 60 then print to the console, Congratulations, you passed.

If the grade is below 60 then print to the console, Sorry, you failed.

Section 3:

Enter the comment with the section title.

Request the user to enter a number, 1 through 12, which will represent the month of the year.

Using an if statement with a series of else if statements, determine which month was entered.

Write the name of the month to the console.

Write an error message if the number proves to be invalid.

Section 4:

Enter the comment with the section title.

Request the user to enter a number, 1 through 7, which will represent the day of the week.

Using a switch statement, determine which day of the week was entered.

Write the name of the day of the week to the console.

Write an error message if the number proves to be invalid.

POSSIBLE EXPECTED OUTPUT

Enter first integer: 3

Enter second integer: 9

3 <> 9

3 < 9

3 <= 9

Enter grade and determine whether you passed: 60

Congratulations, you passed

Enter the number of the month: 7

The Month is July.

Enter the number of the day of the week: 1

Sunday

Unit 2

//IT213 Unit 2 Assignment

using System;

namespace IT213_Your LastName_Unit2

{

class Program

{

//Main is the entry point for your code

static void Main(string[] args)

{

//**

//****Assignment 2 Section 1

//**:

//declare variables for all sections

int number1;

***

*

int number2;

int month;

double grade;

int dayOfWeek;

//Request the user to enter two whole numbers and store those whole numbers in two appropriately defined variables

Console.WriteLine("Enter first integer: ");

number1 = Convert.ToInt32 (Console.ReadLine());

Console.WriteLine("Enter second integer: "); number2 = Convert.ToInt32 (Console.ReadLine());

//Compare the two whole numbers with each of the following comparison

operators. ==, !=, <, >, <=, >=

//Each statement that proves true should print to the console the numbers compared and the comparison made

follow

formatting

// the zero and one in the curly braces reference the variable positions that

// See this link for more on this type of formatting inline: // https://docs.microsoft.com/en-us/dotnet/standard/base-types/composite-

// you could also do something like Console.WriteLine(number1 +

"

"

=

number2);

if (number1

==

number2)

Console.WriteLine("{0} = {1}", number1, number2);

if (number1 != number2)

Console.WriteLine("{0} <> {1}", number1, number2);

if (number1 number2)

Console.WriteLine("{0} < {1}", number1, number2);

if (number1 > number2)

Console.WriteLine("{0} > {1}", number1, number2);

if (number1 <= number2)

Console.WriteLine("{0} <= {1}", number1, number2);

if (number1 >= number2)

Console.WriteLine("{0} >= {1}", number1, number2);

//****Assignment 2 Section 2

//*:

number 60

//Request the user to enter a grade

Console.WriteLine("Enter your grade to see if you passed: ");

grade = Convert.ToInt32 (Console.ReadLine());

//Using an if statement with an else clause, compare the user input with the

//If the grade entered is greater than or equal to 60 then print to the console, "Congratulations, you passed."

//If the grade is below 60 then print to the console, "Sorry, you failed."

if (grade >= 60)

else

Console.WriteLine("Congratulations, you passed.");

Console.WriteLine("Sorry, you failed.");

//*:

//****Assignment 2 Section 3

//***

//Request the user to enter a number for a month Console.WriteLine("Enter the number of the month: ");

month =

Convert.ToInt32 (Console.ReadLine());

//Using an if statement with a series of else if statements, determine which month was entered and display the name of the month

if (month

==

1)

{

Console.WriteLine("The month is January.");

}

else if (month

==

2)

{

Console.WriteLine("The month is February.");

}

else if (month

==

3)

{

Console.WriteLine("The month is March.");

}

else if (month

==

4)

{

Console.WriteLine("The month is April.");

}

else if (month

==

5)

{

Console.WriteLine("The month is May.");

}

else if (month

==

6)

{

Console.WriteLine("The month is June.");

}

else if (month

==

7)

{

Console.WriteLine("The month is July.");

}

else if (month

==

8)

{

Console.WriteLine("The month is August.");

}

else if (month

==

9)

{

Console.WriteLine("The month is September.");

}

else if (month

==

10)

{

Console.WriteLine("The month is October.");

}

else if (month

==

11)

{

Console.WriteLine("The month is November.");

}

else if (month

==

12)

{

}

else

Console.WriteLine("The month is December.");

//Write an error message if the number proves to be invalid Console.WriteLine("Invalid month.");

//****Assignment 2 Section 4

**

//Request the user to enter a number for a day of the week

Console.WriteLine("Enter the number of the day of the week: ");

dayOfWeek

=

Convert.ToInt32(Console.ReadLine());

//Using a switch statement, determine which day of the week was entered and display the day of the week name

switch (dayOfWeek)

{

case 1:

Console.WriteLine("Sunday");

break;

case 2:

Console.WriteLine("Monday");

break;

case 3:

Console.WriteLine ("Tuesday");

break;

case 4:

Console.WriteLine("Wednesday");

break;

case 5:

Console.WriteLine("Thursday");

break;

case 6:

Console.WriteLine("Friday");

break;

case 7:

Console.WriteLine("Saturday");

break;

//Write an error message if the number proves to be invalid. default:

Console.WriteLine("Invalid Day.");

break;

}

//keep console window open

Console.Read();

}

}

}//end of unit 2 program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Publishing With Filemaker Pro On The Web

Authors: Maria Langer

1st Edition

0201696657, 978-0201696653

More Books

Students also viewed these Databases questions

Question

2. How will you handle the situation?

Answered: 1 week ago

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago