Computing Fundamentals-Java Network Programming-Lab Assignment and Solution, Exercises of Java Programming

This handout is related to Java Network Programming course at Indraprastha Institute of Information Technology. It includes: Fortran, Basics, Microsoft, Developer, Studio, Compile, Execute, Program, Variable, Declaration

Typology: Exercises

2011/2012

Uploaded on 07/08/2012

jamil
jamil ๐Ÿ‡ฎ๐Ÿ‡ณ

4

(12)

139 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
๎˜ƒ
๎˜ƒ
๎˜ƒ
INSTRUCTIONS๎˜ƒ
1. Use๎˜ƒMicrosoft๎˜ƒDeveloper๎˜ƒStudio๎˜ƒfor๎˜ƒthe๎˜ƒfollowing๎˜ƒprograms๎˜ƒ
2. Create๎˜ƒnew๎˜ƒfile๎˜ƒfor๎˜ƒeach๎˜ƒof๎˜ƒthe๎˜ƒfollowing๎˜ƒprogram๎˜ƒ
3. Create๎˜ƒa๎˜ƒfolder๎˜ƒโ€œlabโ€2โ€๎˜ƒand๎˜ƒsave๎˜ƒall๎˜ƒthe๎˜ƒfiles๎˜ƒin๎˜ƒthat๎˜ƒfolder๎˜ƒ๎˜ƒ
4. While๎˜ƒleaving๎˜ƒthe๎˜ƒlab๎˜ƒclose๎˜ƒall๎˜ƒprograms๎˜ƒand๎˜ƒshutdown๎˜ƒthe๎˜ƒcomputers๎˜ƒ
5. Do๎˜ƒnot๎˜ƒdiscard๎˜ƒthis๎˜ƒdocument๎˜ƒ
Activity-01 (Execute and Understand )
โ€ข Follow๎˜ƒthe๎˜ƒlecture๎˜ƒslides๎˜ƒand๎˜ƒwrite๎˜ƒyour๎˜ƒfirst๎˜ƒprogram,๎˜ƒCompile๎˜ƒand๎˜ƒexecute๎˜ƒthe๎˜ƒprogram๎˜ƒ
โ€ข Type๎˜ƒthe๎˜ƒfollowing๎˜ƒprograms๎˜ƒexecute๎˜ƒthem๎˜ƒand๎˜ƒunderstand๎˜ƒthe๎˜ƒstatements๎˜ƒused,๎˜ƒin๎˜ƒcase๎˜ƒof๎˜ƒany๎˜ƒconfusion๎˜ƒ
contact๎˜ƒany๎˜ƒresource๎˜ƒperson๎˜ƒavailable๎˜ƒin๎˜ƒlab๎˜ƒ
Program-01
This program will greet you if you give it your name:
! My first Fortran program!
! Greetings!
CHARACTER NAME*20
WRITE*, 'What is your name?'
READ*, NAME
WRITE*, 'Hi there,', NAME
END
You should get the following output (your response is in italics):
What is your name?
ABC
Hi there, AB
Activity-02
The purpose of this activity is to understand the variable declaration and input/output statements along
with simple calculations, write and execute the program and understand its working
Program-02
C234567
X=10
Y=20
Z=X+Y
WRITE(*,*)X,Y,Z ! The expected output is: 10.000 20.0000 30.0000
END
Program-03
1. C234567
2. X=10
3. Y=20
4. write (*,*) 'Enter X:'
5. read (*,*) x
6. write (*,*) 'Enter Y:'
7. read (*,*) Y
8. Z=X+Y
docsity.com
pf2

Partial preview of the text

Download Computing Fundamentals-Java Network Programming-Lab Assignment and Solution and more Exercises Java Programming in PDF only on Docsity!

I NSTRUCTIONS

  1. Use Microsoft Developer Studio for the following programs
  2. Create new file for each of the following program
  3. Create a folder โ€œlabโ€2โ€ and save all the files in that folder
  4. While leaving the lab close all programs and shutdown the computers
  5. Do not discard this document

Activity-01 (Execute and Understand )

  • Follow the lecture slides and write your first program, Compile and execute the program
  • Type the following programs execute them and understand the statements used, in case of any confusion contact any resource person available in lab

Program-

This program will greet you if you give it your name:

! My first Fortran program! ! Greetings!

CHARACTER NAME*

WRITE, 'What is your name?' READ, NAME WRITE*, 'Hi there,', NAME END

You should get the following output (your response is in italics):

What is your name?

ABC

Hi there, AB

Activity-

The purpose of this activity is to understand the variable declaration and input/output statements along with simple calculations, write and execute the program and understand its working

Program-

C X= Y= Z=X+Y WRITE(,)X,Y,Z! The expected output is: 10.000 20.0000 30.

END

Program-

  1. C
  2. X=
  3. Y=
  4. write (,) 'Enter X:'
  5. read (,) x
  6. write (,) 'Enter Y:'
  7. read (,) Y
  8. Z=X+Y

docsity.com

2 Pakistan Institute of Engineering & Applied Sciences

Department of Computer and Information Sciences

9. WRITE(,)X,Y,Z

10. END

Understand the read statementโ€™s operation and try the following modifications

  • Use different variable names instead of X, Y
  • Use more than two variables , get input for each of them and print their sum
  • Try to input more than one value using read statement i.e. read (,) X,Y

Q.What will happen if in program 3 in line 7 Y is replaced with y?

Activity-

Based on the knowledge learnt in activity-02 write code to evaluate the following numeric expressions, given that A = 2, B = 3, C = 5 (reals); and I = 2, J = 3 (integers). Answers are given in parentheses.

A * B + C (11.0)

A * (B + C) (16.0)

B / C * A (1.2)

B / (C * A) (0.3)

A / I / J (0.333333)

I / J / A (0.0)

A * B ** I / A ** J * 2 (4.5)

C + (B / A) ** 3 / B * 2. (7.25)

A ** B ** I (512.0)

- B ** A ** C (-45.0)

J / (I / J) (division by zero)

Activity-

โ€ข Write a program to compute and print the sum, difference, product and quotient of two

numbers A and B (supplied from the keyboard). The symbols for subtraction and division are

  • and / respectively. Use the program to discover how Fortran reacts to an attempted division by zero.

โ€ข The energy stored on a condenser is, where C is the capacitance and V is the

potential difference. Write a program to compute the energy for some sample values of C and V. Solutions to most exercises are in Appendix E.

CV

2

docsity.com