0% found this document useful (0 votes)
59 views7 pages

Ichinoshi Paradiang 47325

The document contains 3 coding problems and their solutions in C#: 1. A program to calculate a student's final grade based on scores in different assessments. It takes input for prelim, midterm, pre-final, final exam and class standing scores, calculates the weighted average and checks if the student passed or failed. 2. A program to determine the direction based on a degree input. It takes a degree between 0-360 and outputs the corresponding cardinal or inter-cardinal direction. 3. A program to calculate a user's current age in years, months and days from their birthdate. It takes input for date of birth and calculates the time elapsed between then and current date.

Uploaded by

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

Ichinoshi Paradiang 47325

The document contains 3 coding problems and their solutions in C#: 1. A program to calculate a student's final grade based on scores in different assessments. It takes input for prelim, midterm, pre-final, final exam and class standing scores, calculates the weighted average and checks if the student passed or failed. 2. A program to determine the direction based on a degree input. It takes a degree between 0-360 and outputs the corresponding cardinal or inter-cardinal direction. 3. A program to calculate a user's current age in years, months and days from their birthdate. It takes input for date of birth and calculates the time elapsed between then and current date.

Uploaded by

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

Ichinoshi Paradiang

47325

Problem 1:
1. Create program that will compute for the student’s final grade with the
following conditions:
a. Your program will ask for the students Prelim, Midterm, Pre-final, Final
and Class Standing grades.
b. Prelim grade (17.5%), Midterm (20%), Pre-final (17.5%), Finals (30%),
CS (15%)
c. Your program will determine if the Final Grade passed/failed the
subject. Passing grade should be 75 or above.
Sample Output:
Prelim:82
Midterm:75
Pre-Final:70
Finals:74
CS:80
Final Grade:76
You Passed!
Codes:

using System;

public class HelloWorld


{
static public void Main ()
{
Console.Write("Prelim : ");
double prelim = int.Parse(Console.ReadLine()) * .175;
Console.Write("Midterm : ");
double midterm = int.Parse(Console.ReadLine()) * .2;
Console.Write("Prefinal : ");
double prefinal = int.Parse(Console.ReadLine()) * .175;
Console.Write("Finals : ");
double finals = int.Parse(Console.ReadLine()) * .3;
Console.Write("CS : ");
double cs = int.Parse(Console.ReadLine()) * .15;
double sum = (prelim + midterm + prefinal + finals + cs);

Console.Write("Final Grade : " + sum );


if (sum >= 75)
Console.WriteLine("You Passed!");
else
Console.Write("You Failed!");
Console.ReadKey();
}
}
Write a program that will determine the direction based on the
Problem 2.
inputted number
Sample Output:
Enter Direction in Degrees: 87
Direction:NorthEast

Codes:

using System;

public class random3


{
static public void Main ()
{

int dr;
Console.Write("Enter Direction in Degrees: ");
dr=Convert.ToInt32(Console.ReadLine());
Console.WriteLine(dr);
string drString = "";
if(dr==0 && dr==360){
drString="East";
}else if(dr>270){
drString="South East";
}else if(dr==270){
drString="South";
}else if(dr>180){
drString="South West";
}else if(dr==180){
drString="West";
}else if(dr>90){
drString="North West";
}else if(dr==90){
drString="North";
}else if(dr>0){
drString="North East";
}else{
Console.WriteLine("Invalid!!!");
}

Console.WriteLine("Direction: {0}", drString);

}
}
Problem 3. Create a program that will ask for the user’s birthdate. Then print
user’s age in number of years, months and days passed his/her birthdate.
Sample Output:
Input Birthday
Month:January
Date:5
Year:2000

You are now 20 years 9 months and 6 days old.

Codes:
using System;

public class CodesForNum1


{
static public void Main ()
{
int yr=DateTime.Now.Year;
int mo=DateTime.Now.Month;
int dy=DateTime.Now.Day;
Console.WriteLine("Today is {0}/{1}/{2}", mo,dy,yr);
int mi=0;
Console.Write("Input Month: ");
string mn=Console.ReadLine();
Console.WriteLine(mn);
Console.Write("Input Day: ");
int di=Convert.ToInt32(Console.ReadLine());
Console.WriteLine(di);
Console.Write("Input Year: ");
int yi=Convert.ToInt32(Console.ReadLine());
Console.WriteLine(yi);
if(mn=="January"){
mi=1;
}else if(mn=="February"){
mi=2;
}else if(mn=="March"){
mi=3;
}else if(mn=="April"){
mi=4;
}else if(mn=="May"){
mi=5;
}else if(mn=="June"){
mi=6;
}else if(mn=="July"){
mi=7;
}else if(mn=="August"){
mi=8;
}else if(mn=="September"){
mi=9;
}else if(mn=="October"){
mi=10;
}else if(mn=="November"){
mi=11;
}else if(mn=="December"){
mi=12;
}
int mtot = mi-mo;
int ytot=0;
int abs = mtot*-1;
int abs2=abs-1;
int dtot=dy-di;
int dtot2=0;

if(dtot<0){
dtot2=dtot+31;
}
if(mi>=mo){
ytot=(yr-yi)-1;
Console.WriteLine("You are now {0} years {1} months and {2}
days old", ytot,mtot,dtot2);
}else{
ytot=yr-yi;
Console.WriteLine("You are now {0} years {1} months and {2} days
old", ytot,abs,dtot);

}
}

You might also like