0% found this document useful (0 votes)
32 views

Week3 Lab

This document outlines two assignments for a lab. The first assignment has students implement simple input/output examples including reading integers for a birthday, performing math operations, and not proving an equation. The second assignment has students input information for two students such as name, age, GPA, gender, ID, year, and credits. It then generates a report summarizing the information for each student.

Uploaded by

rajwosa
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)
32 views

Week3 Lab

This document outlines two assignments for a lab. The first assignment has students implement simple input/output examples including reading integers for a birthday, performing math operations, and not proving an equation. The second assignment has students input information for two students such as name, age, GPA, gender, ID, year, and credits. It then generates a report summarizing the information for each student.

Uploaded by

rajwosa
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/ 2

Lab #1

In this assignment you are supposed to write simple I/O applications.


1. Implement and run the follwing examples:
a. You have no input but your output is:
There are two ways of spreading light:

To be the candle, or the mirror that reflects it.


b. You have no input but your output is:
“There are two ways of spreading light:

To be the candle, or the mirror that reflects it.”


c. You read three integers as the input data of someone’s birthday and your output is:
Enter a your birthday as day month year:
16 5 2002
Congratulations! Your birthday is 16-5-2002
You are (2007-2002)= 5 years old
d. You read three integers as the input data and your output is:
Enter three integers: 2 3 5
2+3+5= 10
2-3-5= -6
2*3*5= 30
Num1*(Num2+Num3)
is not equal to
Num1*Num2+Num3
Proof:
=====
2*(3+5)=16 is not equal to 2*3+5=11

2. You will ask the user his/her name initials, age, gpa, gender, id, year and the #credits he/she enrolled for this
semester. Then you will write a small report that gives information about the user according to the following
rules:
a. Input name, surname initials followed by a dot, age, year and gpa as the first line
b. Input gender on the second line.
c. Input id and #credits taken that semester on the third line.
d. Assume that you will read these data for two students. Then you will write a report about them.
Example run :
First Student:
Enter your name, surname initials followed by a dot, age, and gpa: A. K. 20 2 3.75
Enter your gender F(emale) M(ale): M
Enter your id and #credits you have taken this semester: 1234 28

Second Student:
Enter your name, surname initials followed by a dot, age, and gpa: Z. Z. 21 3 3.70
Enter your gender F(emale) M(ale): F
Enter your id and #credits you have taken this semester: 1342 27

Report:
=====================================================
First Student:
--------------
Name Surname: A. K. Gender: M
Age : 20 ID : 1234
Year :2 GPA : 3.75
You have taken 28 credits.
=====================================================
Second Student:
----------------
Name Surname: Z. Z. Gender: F
Age : 21 ID : 1342
Year :3 GPA : 3.70
You have taken 27 credits.

You might also like