Sei sulla pagina 1di 9

Q1) Write a program to input student no, name &marks If marks, 80-100 => D 75-79 => C 70-74=>S BELOW

70 =>F Display student no and grade on screen. FLOW CHART Start

Student No Name Marks Ma

YES If marks >= 80 Grade = D

NO If marks >= 75

YES Grade = C

NO If marks >= 70 NO Grade = F

YES Grade =S

End

FUNCTION LIST 1. Start 2. Declare Variable Student NO, Name , Grade 3. Input Student NO, Name , Grade 4. Grade = D 5. Grade = C 6. Grade = S 7. Grade = F 8. Display Name , Grade 9. End

CONDITION LIST If marks >= 80 Do 4 Else If marks >= 75 Do 5 Else If marks >= 70 Do 6 Else Do 7

STRUCTURE CHART Stat


Begin Body

End 8,9

1,2,3 if

if

Else

if 5

Else

CODING WINDOWS FORM APPLICATION METHOD

private void button1_Click(object sender, EventArgs e) { int studno,marks; string studname, grade; studname = txtstuname.Text; marks = Convert.ToInt16(txtmarks.Text); studno = Convert.ToInt16(txtstuno.Text); if (marks >= 80) { grade = "D"; } else if (marks >= 75) { grade = "c"; } else if (marks >= 70) { grade = "s"; } else { grade = "f"; } MessageBox.Show("student no :" + studno + Environment.NewLine + "studname:" + studname + Environment.NewLine + "Grade:" + grade); }

DESIGN VIEW

CONSOLE BASE APPLICATION METHOD

static void Main(string[] args) { int studentnumber, marks; String studentname, grade; Console.WriteLine("enter value for studentnumber"); studentnumber = Convert.ToInt16(Console.ReadLine()); Console.WriteLine("enter value for marks"); marks = Convert.ToInt16(Console.ReadLine()); Console.WriteLine("enter value for studentname"); studentname = (Console.ReadLine()); grade = (Console.ReadLine()); if (marks > 80) { grade = "D"; } else if (marks > 75) { grade = "c"; } else if (marks > 70) { grade = "s"; } else { grade = "f"; } Console.WriteLine("studentnumber:{0} studentname:{1} grade:{2} ", studentnumber, studentname, grade);

DESIGN VIEW

Q2) A Program is to be written to handle the process of entering membership information for a leisure center. First of all the surname is to be entered followed by the first name. Next the address is to be entered a then the age. If the person is under 16 years old junior is to be entered into the status field and 25$ is to be entered to the membership fee field. But if the person is 16 years old or more than 16 then Senior is to be entered into the status field and 50$ is to be entered to the membership fee field. Finally display all the details on screen.

CODING WINDOWS FORM APPLICATION METHOD

private void button1_Click(object sender, EventArgs e) { string Surname,Lastname,Address,Status; int age,MembershipFee; Surname = txtsurname.Text; Lastname = txtfullname.Text; Address = txtaddress.Text; age = Convert.ToInt16(txtage.Text); if (age < 16) { Status = "JUNIOR"; MembershipFee = 25; } else { Status = "SENIOR"; MembershipFee = 50; } MessageBox.Show("Surname :" + Surname + Environment.NewLine + "Address:" + Address + Environment.NewLine + "Age" + age + Environment.NewLine + "Status:" + Status + Environment.NewLine + "Membership Fee:" + MembershipFee); }

DESIGN VIEW

CONSOLE BASE APPLICATION METHOD

static void Main(string[] args) { string Surname, Lastname, Address, Status; int Age, MembershipFee; Console.WriteLine("enter value for surname"); Surname = (Console.ReadLine()); Console.WriteLine("enter value for lastname"); Lastname = (Console.ReadLine()); Console.WriteLine("enter value for address"); Address = (Console.ReadLine()); Console.WriteLine("enter value for age"); Age = Convert.ToInt16(Console.ReadLine()); if (Age < 16) { Status = "JUNIOR"; MembershipFee = 25; } else { Status = "SENIOR"; MembershipFee = 50; } Console.WriteLine("Surname:{0} ",Surname); Console.WriteLine("Address:{0} ",Address); Console.WriteLine("Age:{0} ",Age); Console.WriteLine("Status:{0}",Status); Console.WriteLine("MembershipFee:{0} ",MembershipFee); }

DESIGN VIEW

FLOW CHART

Start

Surname Last name Address Age

YES If age < 16

Status: - JUNIOR Membership fee = 20$

NO

Status: - SENIOR Membership fee = 50$

End

FUNCTION LIST 1. Start 2. Declare Variable Surname, Lat name, Address, Age 3. Input Surname, Lat name, Address, Age 4. Status junior, Membership Fee 20$ 5. Status senior, Membership Fee 50$ 6. Display Surname, Address, Age, senior, Membership Fee 7. End

CONDITION LIST If age < 16 Do 4 Else Do 5 if age >=16

STRUCTURE CHART Stat

Begin 1, 2, 3

Body

End 6, 7

IF

ELSE

Potrebbero piacerti anche