Docsity

Fortran Programming - Lab 3 - Fall 2009 | CSCI 260, Lab Reports of Computer Science

Toggle sidebar
bg1
CSCI260 Lab 3 Spring 2009
Due: 11:59pm. Wednesday, January 28, 2009
Objective: Using IF statements to do selective execution of code. Coding scientific equations -
Your program will get data from the user, perform computations dependent on input
values and output results.
Overview: You will be provided a Fortran shell with comments to lead you through the program’s
development. The equations and process for decision making that you will use are
provided below. You will write the code to prompt the user for the values of those
variables. This prompting process is similar to the process used in lab2.
Specific Instructions:
Part I. Environment Setup.
1. Login to the isengard system
2. Go inside your csci260a folder:
cd csci260a
3. Now create a folder to hold this week’s Fortran programs:
mkdir lab3
4. Go into your lab3 directory:
cd lab3
5. Copy the starter program files into your current directory:
cp /class/csci260a/Assignments/lab3/* .
Lesson #1
1. For safety, you will now make a duplicate of this file:
cp lesson1.f95 mylesson1.f95
2. Load the mylesson1.f95 file into the text editor of your choice.
xemacs mylesson1.f95 &
3. Make the following modifications to the file:
§Change, as indicated, the header information area. Make sure each line in the header
area begins with an exclamation mark.
Australia is a truly wonderful place to live, but it is also a land of high taxes. In 2002,
individual citizens and residents of Australia paid the following income taxes:
Taxable Income Tax on this Income
$0 - $6,000 Nil
$6,001 - $20,000 17 cents for each $1 over $6,000
$20,001 - $50,000 $2,380 plus 30cents for each $1 over $20,000
$50,001 - $60,000 $11,380 plus 42cents for each $1 over $50,000
Over $60,000 $15,580 plus 47cents for each $1 over $60,000
pf3

Partial preview of the text

Download Fortran Programming - Lab 3 - Fall 2009 | CSCI 260 and more Lab Reports Computer Science in PDF only on Docsity!

Due : 11:59pm. Wednesday, January 28, 2009 Objective : Using IF statements to do selective execution of code. Coding scientific equations - Your program will get data from the user, perform computations dependent on input values and output results. Overview : You will be provided a Fortran shell with comments to lead you through the program’s development. The equations and process for decision making that you will use are provided below. You will write the code to prompt the user for the values of those variables. This prompting process is similar to the process used in lab2. Specific Instructions: Part I. Environment Setup.

  1. Login to the isengard system
  2. Go inside your csci260a folder: cd csci260a
  3. Now create a folder to hold this week’s Fortran programs: mkdir lab
  4. Go into your lab3 directory: cd lab
  5. Copy the starter program files into your current directory: cp /class/csci260a/Assignments/lab3/. Lesson #*
  6. For safety, you will now make a duplicate of this file: cp lesson1.f95 mylesson1.f
  7. Load the mylesson1.f95 file into the text editor of your choice. xemacs mylesson1.f95 &
  8. Make the following modifications to the file: § Change, as indicated, the header information area. Make sure each line in the header area begins with an exclamation mark. Australia is a truly wonderful place to live, but it is also a land of high taxes. In 2002, individual citizens and residents of Australia paid the following income taxes:

Taxable Income Tax on this Income

$0 - $6,000 Nil

$6,001 - $20,000 17 cents for each $1 over $6,

$20,001 - $50,000 $2,380 plus 30cents for each $1 over $20,

$50,001 - $60,000 $11,380 plus 42cents for each $1 over $50,

Over $60,000 $15,580 plus 47cents for each $1 over $60,

In addition, a flat 1.5 percent Medicare levy is charged on all income. Write a program to calculate how much income tax a person owes based on this information. The program should accept a total income figure from the user and calculate the income tax, Medicare levy, and total tax payable by the individual. Use good programming practices in your program. You will need variables for:: income, Medicare tax, income tax, total tax, and what is left after the government has taken it's share. You can use IF THEN statements with compound logical expressions or you can use nested IF THEN ELSE statements.

  1. Save your modified file.
  2. Compile your program. g95 mylesson1.f
  3. If there are errors, re-edit mylesson1.f95 to fix the bugs and then re-compile. When it compiles with no errors, run the compiled program using a.out Make sure the computations are correct. Create several test cases with arbitrary values. Remember, error free compilation does not guarantee correct calculations. Lesson 2 – Problem Solving
  4. For safety, you will now make a duplicate of this file: cp lesson2.f95 mylesson2.f
  5. Load the mylesson2.f95 file into the editor of your choice. xemacs mylesson2.f95 & Write a program that mimics a calculator. The program should take as input two integers and the operation to be preformed. It should then output the numbers the operator,and the results. (For division, if the denominator is zero, output an appropriate message.) Example of interaction of program: Welcome to the CSCI260 calculator. Input a number, an operator and another number (operators +,-,,div,*). 3.1 div 1. 3.1 / 1.2 = 2. The '/' symbol in UNIX and Fortran gets confused with another ASCII character, so, use 'div'. The variable to hold the operator should be CHARACTER (len=3):: Last Part. Prepare and submit your project.
    1. Your submittal will be your Script file: script lab3.script