0% found this document useful (0 votes)
32 views4 pages

DCIT 318-Assignment 1-10882603

Uploaded by

Daniel JDanso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views4 pages

DCIT 318-Assignment 1-10882603

Uploaded by

Daniel JDanso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

DCIT 318: PROGAMMING II

ASSIGNMENT 1
ID: 10882603

Q1: Grade Calculator

Write a program that prompts the user to enter a numerical grade between 0 and 100. Based
on the grade entered, display the corresponding letter grade using the following scale:

·         90 and above: A

·         80-89: B

·         70-79: C

·         60-69: D

·         Below 60: F

Solution

using System;

class Grade Calculator


{
static void Main()
{
Console.WriteLine("Enter a numerical grade between 0 and 100:");
int grade = Convert.ToInt32(Console.ReadLine());

char letterGrade;

if (grade >= 90)


letterGrade = 'A';
else if (grade >= 80)
letterGrade = 'B';
else if (grade >= 70)
letterGrade = 'C';
else if (grade >= 60)
letterGrade = 'D';
else
letterGrade = 'F';
Console.WriteLine($"Your Letter grade is: (letterGrade)");
}
}

 
Q2: Ticket Price Calculator

A movie theater sells tickets for GHC10. However, if a customer is a senior citizen (age 65
and above) or a child (age 12 and below), they receive a discounted price of GHC7. Write a
program that prompts the user to enter their age and calculates the ticket price based on the
age entered. Display the ticket price accordingly.

Solution

using System;

class Ticket_Price_Calculator
{
static void Main()
{
int t_price = 10;

Console.WriteLine(“Enter your age”);


int age = ConvertToInt32(Console.ReadLine());

int d_price = 7;

if (age >= 65 || age<=12)


Console.WriteLine($“Your ticket price is GH¢ {d_price}”);
else
Console.WriteLine($“Your ticket price is GH¢ {t_price}”);
}
}

Q3. Triangle Type Identifier

Write a program that prompts the user to enter three sides of a triangle. Based on the lengths
of the sides entered, determine and display the type of the triangle. The possible types are:

·         Equilateral: All three sides are equal.

·         Isosceles: Two sides are equal.

·         Scalene: No sides are equal.

 Solution

using System;

class Triangle_Type_Identifier
{
static void Main()
{
Console.WriteLine("Enter the length of the first side:");
double side1 = Convert.ToDouble(Console.ReadLine());

Console.WriteLine("Enter the length of the second side:");


double side2 = Convert.ToDouble(Console.ReadLine());

Console.WriteLine("Enter the length of the third side:");


double side3 = Convert.ToDouble(Console.ReadLine());

if (side1 == side2 && side2 == side3)


{
Console.WriteLine("The triangle is an equilateral triangle");
}
else if (side1 == side2 || side1 == side3 || side2 == side3)
{
Console.WriteLine("The triangle is Isosceles");
}
else
{
Console.WriteLine("The triangle is a Scalene triangle");
}
}
}

Q5. Menu Selector

Create a program that displays a menu with three options: 1) Play, 2) Pause, and 3) Stop.
Prompt the user to enter a choice. Based on the choice entered, display a corresponding
message. Use a switch statement to handle the menu selection.

Solution

using System;

class Menu_Selector
{
static void Main()
{
Console.WriteLine("Menu:");
Console.WriteLine("1) Play");
Console.WriteLine("2) Pause");
Console.WriteLine("3) Stop");

Console.WriteLine("Enter your preferred option (1-3):");


int option = Convert.ToInt32(Console.ReadLine());

switch (option)
{
case 1:
Console.WriteLine("Playing...");
break;
case 2:
Console.WriteLine("Paused.");
break;
case 3:
Console.WriteLine("Stopped.");
break;
default:
Console.WriteLine("Invalid option.");
break;
}
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy