3 Pages

Programming Assignment #2

Course: EE 312, Spring 2008
School: University of Texas
Rating:
 
 
 
 
 

Word Count: 1187

Document Preview

1 Page of 3 Assignment 2 Manipulating Numeric Data EE312 - The University of Texas at Austin - Spring 2008 Assigned: Tuesday, Jan. 29 Due: Thursday February 7 before midnight. Value: 20 points (for correctness of the program) File submitted: submit (upload) the final version of your C source code file (.c file) to the Blackboard's assignment manager for this assignment of your section of this course. Purposes:...

Register Now

Unformatted Document Excerpt

Coursehero >> Texas >> University of Texas >> EE 312

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
1 Page of 3 Assignment 2 Manipulating Numeric Data EE312 - The University of Texas at Austin - Spring 2008 Assigned: Tuesday, Jan. 29 Due: Thursday February 7 before midnight. Value: 20 points (for correctness of the program) File submitted: submit (upload) the final version of your C source code file (.c file) to the Blackboard's assignment manager for this assignment of your section of this course. Purposes: to learn how to input and output numeric values using formatted IO commands to learn how to define and symbolically manipulate numeric data to learn how to use program control statements to perform looping and decision making The problem: We take a loan for many things that we buy. For this assignment we will create a simplified loan banking information system. The system will provide the following capabilities to the customer (user). 1. Case 1: It will calculate and report the estimated monthly installment (EMI) for the required loan principal for a loan of a given term. The borrower will pay simple interest on the loan of a fixed rate of 20% of the loan amount. [Economics note: In this example, we're using simple interest to keep the calculations relatively straightforward. Real loans are based on compounding interest.] 2. Case 2: In the case that the customer wants to pay more than the EMI each month (e.g., a fixed percentage of EMI additionally) then the system will calculate the way that the monthly payments correspondingly decrease over the term of the loan. [Economics note: In this example, there is no real benefit to the borrower in paying early on his loan. This is because, to keep the example simple, we're not recalculating the interest when the borrower prepays. In the real world with compounding interest, the amount paid to the lender would reduce if the borrower pre-paid.] Your program will need to perform the following input, process, and output steps repeatedly until the customer decides that no more operations are needed (Case 3). Inputs: Your program should input values from the keyboard using scanf( ). Use appropriate prompt messages (i.e., output messages) to tell the user what needs to be input at any point in the dialog. Your program should work correctly for all legitimate values that are input (defined below). If a bad input value is given then your program should either: terminate or give a bad output value. Given that the user wants to potentially do two different operations with the system, there are two different sets of numeric inputs the user might give your program. To start with, the user inputs (when prompted) a 1 to calculate the EMI for a new loan, or a 2 to calculate monthly payments given that he wants to prepay his loan, or a 3 to end the program. Subsequent inputs should depend on this selection: Page 2 of 3 1. Case 1: To calculate the EMI, your program should request the value of the principal loan amount (as a float) and the number of months of the loan term (as an integer) 2. Case 2: To calculate new EMI amounts given prepayments, the user should be asked to input the value of the principal (as a float), the number of months in the term of the loan (as an integer) and the percentage of the EMI the user intends to prepay each month (as a float). 3. Case 3: The customer has finished using the system for EMI operations, and wishes to terminate the program. Your system should output a goodbye/thank you message in that case and then terminate. Processing: The following information provides some details about the expected behavior of your program and some hints about the design of the algorithm. 1. The basic EMI can be calculated using the following equation (which assumes 20% simple interest). This is formula not in C. EMI = (Principal +Principal*20/100)/Term 2. Our bank is a nice bank that reduces the borrower's EMI when he pays early. Your program should assume that the borrower intends to prepay by EMI*PrepayPercentage each month and calculate the remaining payment amounts for the term of the loan. 3. The following high-level algorithm might give you some idea about how to calculate a set of monthly payments given that the borrower is paying on his loan balance early: Calculate the loan Balance (assuming 20% simple interest) Calculate the following for Each Month of the term: Calculate the new EMI Calculate the Prepayment (EMI * PrepayPercentage) Calculate the Payment Calculate the remaining Balance 4. Tip: When your borrower pays down his loan early, be careful that he isn't instructed to pay beyond the balance of his loan! If you can accept the above inputs and produce the correct outputs (exemplified below), you may perform the processing in any manner that you want. Outputs: The results of output using printf( ) should show in the terminal window in a form that is understandable by an ordinary human being. They should provide the information described next for each case. 1. Case 1: The program should output to the screen the EMI (as a float) and the total amount paid by the borrower (again, as a float). A sample output might be (user inputs are shown in bold): Good morning! Welcome to the EE312 Bank. Please select from the following choices: Press 1 to calculate the EMI for a new loan. Press 2 to calculate payment amounts for prepaying a loan. Press 3 to exit. 1 Page 3 of 3 Enter the loan's principal: 100000.00 Enter the loan's term (in months): 6 Thank you. Your estimated monthly payment (EMI) for each month is: $20000.00 2. Case 2: In the second case, the program should output a list of the borrower's payments for each month in the term of the loan (with the prepayment amount included) and the balance remaining at the end of that month. A sample output might be (user inputs are shown in bold): Good morning! Welcome to the EE312 Bank. Please select from the following choices: Press 1 to calculate the EMI for a new loan. Press 2 to calculate payment amounts for prepaying a loan. Press 3 to exit. 2 Enter the loan's remaining principal: 100000.00 Enter the number of months remaining on the loan's term: 6 Enter the intended percentage of prepayment: 10.0 Thank you. Here are your calculated payment amounts and the balance at the end of each month: Month Payment Amount Remaining Balance 1 22000.00 98000.00 2 21560.00 76440.00 3 21021.00 55419.00 4 20320.30 35098.70 5 19304.29 15794.42 6 15794.42 0.00 Additional considerations: Write your program using appropriate C language constructs: e.g., constants, variables, declaration statements, assignment statements, input/output methods, numeric expressions and other required "plumbing" to do the computations. As part of the required documentation header block, the top four lines of the file that is submitted should be comments with the following information: // your name - last name, first name // your student EID // your unique section number // EE312-Assignment n - where n is the assignment number (1, 2 ...) You will lose points if you forget to include the header documentation in your submitted file. Along with the required header information also be sure to put comments in your program that would assist in your explaining what your program does. You will not be required to follow the C programming language style guidelines on this assignment, but you will on the next one. Remember that no late assignments will be accepted. Turning in something is always better than nothing.
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

University of Texas - EE - 312
\
University of Texas - ECON - 304K
Definitions for First Midterm Economics 304K: Principles of Microeconomics Prof. Meg LedyardYou are responsible for knowing the definitions below. The definitions from the text are fine. There will NOT be a separate definitions section this semester
University of Texas - PHY - 303K
homework 06 FONTENOT, BRIAN Due: Feb 25 2008, 4:00 am 4. N 480 N Question 1, chap 7, sect 1. part 1 of 3 10 points Assume you are on a planet similar to Earth where the acceleration of gravity g 10 m/s2 . A plane 50 m in length is inclined at an
University of Texas - EE - 312
EE 312 Notes February 19, 2008Quiz for Friday Write a function to subtract two matrices from each other Write a function that takes no parameters and returns a random integer between 1 and 10 inclusive Question 13.3 Question 13.5 (a) Exams will be
University of Texas - ECON - 304K
HW #2 Economics 304K: Principles of Microeconomics Prof. Meg Ledyard Due Thursday, 9/27/07(25 Points total) Remember to type the homework except for charts and graphs. In order to get full credit, you must show all of your work. Homework is due in c
University of Texas - EE - 312
Announcements Lecture 2/28 Assignment 4 Designs due on Tuesday in class Q&AInput file: 1 299 492 495 399 492 495 399 283 279 689 078 100 000 000 000Your DecMack Emulator(from a text file on disk)DecMack Machine language program Topics for
University of Texas - EE - 312
10 299 492 495 399 492 495 399 283 279 689 078 100 000 000 000 456 789 234 453 125 175 183 256 012 100 000 212 415 521 721 532 439 543 631 339 923 029 873 674 027 023 610 621 632 643 654 665 676 687698 609 201 805 229 429 100 100 456 789 234 453 12
University of Texas - EE - 312
Assignment 4: Computer EmulationEE312 The University of Texas at Austin Spring 2008 Assigned: Tuesday Feb 26 Design due: March 4, at the beginning of class Program due: Thursday, Mar 6, 11:59PM Total Value: 20 points total (see Deliverables below
University of Texas - EE - 312
Lecture 12 Announcements Assignment 3 Due today before midnight; Q&AFriday's Quiz Write a program named cntword that counts the number of words in a text file (a word is any sequence of non-white-space characters). Obtain the file name from the
University of Texas - EE - 312
Assignment 3: Fun with Primes Assigned: Design Due: Program Due: Total Value: EE312 The University of Texas at Austin Spring 2008 Tuesday, February 12th Tuesday, February 19, at the beginning of class Tuesday, February 26, before midnight 20 po
University of Texas - EE - 312
Assignment 1: Introduction to the LRC Lab, Visual Studio, and CEE312 The University of Texas at Austin Spring 2008 Assigned: Due: Value: Tuesday, January 15, 2008 Thursday, January 24, 2008, before midnight 20 points (for successfully submitting a
University of Texas - EE - 312
Announcements Assignment 4 D i Designs due RIGHT NOW d RIGHT NOW Due Thursday before midnight Topics for today RecursionRecursion Recursion in C is simply when a function calls itself It is also an important problem solving approach A fun
University of Texas - EE - 312
Announcements Assignment 3 D Due next Tuesday by midnight t T d b id i ht Assignment 4 Out next Tuesday Out next Tuesday I'm out of town all next week Professor Krasner will be in next week to continue lectures Professor Krasner will be in n
University of Texas - EE - 312
Weekly ScheduleM 9:00 Nikhil Nikhil 10:00 Shadi, Nikhil Shadi, Nikhil, Sunil 11:00 Shadi, Nikhil, Sunil Shadi, Nikhil, Sunil 12:00 Shadi, Sunil Shadi 13:00 Mahesh Mahesh 14:00 Mahesh Shadi, Mahesh 15:00 Shadi, Mahesh Shadi, Mahesh 16:00 Shadi, Mahes
University of Texas - EE - 312
Announcements Assignment 2 Offi Office Hours today d Topics for today Type conversions and casting Typedef and sizeof arrays 1D arrays 1DUsual Arithmetic Conversions in Expressions Promotions, e.g: A + B Promotions e g: A + BIn mixed type
University of Texas - EE - 312
Announcements Assignment 2 due today! Exam 1 next Thursday 50 minute exam (9:30 10:20) Topics for today Functions Scope of variables1Functions in a Nutshell A named collection of statements Somewhat like mathematical functions: y = f(
University of Texas - EE - 312
Announcements Assignment 2 Topics for today i f d Partially filled arrays Array algorithms Array algorithms Multidimensional arraysPartially Filled Array Arrays cannot grow after they have been allocated p ( ) y You can allocate more space
University of Texas - EE - 312
Announcements Blackboard Discussion Blackboard Discussion Avoid emailing your TAs with questions about assignments/lectures Course Communication Groups Opt out by today 5pm Optout by today 5pm For today: Finish floating point numbers Format
University of Texas - EE - 312
Announcements Assignment 3 out today Assignment 3 and 4 logisitics Exam 1 Thursday 55 minute exam (9:30 10:25) Program Development Measurement g p SLOC, person hours, logic defects Topics for today Topics for today Scope of variables Ex
University of Texas - EE - 312
Announcements Assignment 3 Exam 1 Graded Back in recitations on Friday Statistics on Thursday (hopefully) Read Chapters 11,12, 13 and 22 Topics for today Matrices Random numbers Strings (time permitting)Review: 2D Arrays Used for table
University of Texas - EE - 312
Announcements Assignment 2 posted today Assignment 2 posted today Quizzes C Coding Style C C di S l For today: Finish looping control statements (Chap. 6) More on types (Chap. 7)For loop The for statement has the formfor ( expression1 ; exp
University of Texas - EE - 312
E E 312 Notes 2.5Arrays Matrix Int variable [r][c] Int my2Darray [3,3] o That means evaluate 3 for 3 Use for statement and nested loops Allows you to make a change in the rows and columns Scan ( %f, &energy[][]); 2d arrays Not easier for us to do
University of Texas - EE - 312
E E 312 Notes February 7, 2008--A named collection of statements o Somewhat like mathematical functions o Arguments are not required Does not need to return a value Functions are like "mini-programs" called by name Top line: declarations Libra
University of Texas - EE - 312
E E 312 Notes February 12, 2008Know Source Lines of Codes Know how many hours you spent on your assignment o Need to do this for Assignment #2 Global Variables o Also called external variables o Are declared outside of your main function o Should
University of Texas - EE - 312
Announcements Assignment 1 due tonight Assignment 1 due tonight Blackboard assignment manager More on Blackboard discussion board More on Blackboard discussion board getchar() For today: Introduction to algorithm design using flowcharts or ps
University of Texas - EE - 312
EE 312 Notes--------Malloc = sets a memory block for the size of bytes you need o Used as a pointer o Ex: p = malloc(sizeof(int); o Will return null if cannot find size o Make sure to check for null Calloc= allocates space for an ar
University of Texas - EE - 312
EE312 Lecture 2 Announcements Topics for today will answer the questions: Survey Results What is the C programming language ? What is C syntax ? What is C s nta ? Assignment statement Numerical expressions Numerical expressions Number stora
University of Texas - EE - 312
Weekly ScheduleM 9:00 Nikhil Nikhil 10:00 Shadi, Nikhil Shadi, Nikhil, Sunil 11:00 Shadi, Nikhil, Sunil Shadi, Nikhil, Sunil 12:00 Shadi, Sunil Shadi 13:00 Mahesh Mahesh 14:00 Mahesh Shadi, Mahesh 15:00 Shadi, Mahesh Shadi, Mahesh 16:00 Shadi, Mahes
University of Texas - EE - 312
16 Frequency Table Type Instruction count 0 3 1 1 2 3 3 2 4 4 5 0 6 3 7 0 8 0 9 0 5 Frequency Table Type Instruction count 0 0 1 1 2 1 3 0 4 2 5 0 6 0 7 1 8 0 9 0 835 Frequency Table Type Instruction count 0 822 1 1 2 1 3 1 4 2 5 3 6 2 7 1 8 1 9 1 15
University of Texas - EE - 312
EE312 Introduction to Programming I d i P iSpring 2008 Christine Julien Christine Julien Assistant Professor c.julien@mail.utexas.edu Office: ACES 5.140 Offi ACES 5 140 Office Hours: TTh: 1112:30Introductions The Teaching Team Instructor Chris
University of Texas - PHY - 303K
homework 05 FONTENOT, BRIAN Due: Feb 18 2008, 4:00 am Question 1, chap 5, sect 5. part 1 of 2 10 points A child holds a sled on a frictionless, snowcovered hill, inclined at an angle of 26 . F87 N 01Question 4, chap 5, sect 5. part 2 of 2 10 p
University of Texas - EE - 312
E E 312 Notes 1.27For Loops For (expression 1; expression 2; expression 3) statement Ex: for (i=10; I > 0; i-) o Printf("T Minus %d and counting\n", i) - I is at 10, check if I is greater than zero, then decrement I and go back and check to see if
University of Texas - PHY - 303K
oldmidterm 01 FONTENOT, BRIAN Due: Feb 14 2008, 3:00 pm Question 1, chap 1, sect 5. part 1 of 1 10 points A newly discovered Jupiter-like planet has an average radius 10.6 times that of the Earth and a mass 313 times that of the Earth. Calculate th
University of Texas - PHY - 303K
midterm 01 FONTENOT, BRIAN Due: Feb 13 2008, 11:00 pm1Mechanics - Basic Physical ConceptsMath: Circle: 2 r, r2 ; Sphere: 4 r2 , (4/3) r3 b2 Quadratic Eq.: a x2 + b x + c = 0, x = -b 2 a-4 a cCartesian and polar coordinates: y x = r cos ,
University of Texas - EE - 312
E E 312 Discussion Notes How to Read arrays: /* Int couter, coutner2 For (coutner=0, array[coutner] < nextinput; coutner+); For (counter 2= arraysize; counter2>count; coutner2 -) { Array[count2]=array[count 2-1]; Arrayszie+ Scanf("); */
University of Texas - PHY - 303K
homework 04 FONTENOT, BRIAN Due: Feb 11 2008, 4:00 am Question 1, chap 4, sect 5. part 1 of 3 10 points An athlete swings a 6.72 kg ball horizontally on the end of a rope. The ball moves in a circle of radius 0.995 m at an angular speed of 0.787 re
University of Texas - PHY - 303K
homework 04 FONTENOT, BRIAN Due: Feb 11 2008, 4:00 am Question 1, chap 4, sect 5. part 1 of 3 10 points An athlete swings a 6.72 kg ball horizontally on the end of a rope. The ball moves in a circle of radius 0.995 m at an angular speed of 0.787 re
University of Texas - PHY - 303K
homework 05 FONTENOT, BRIAN Due: Feb 18 2008, 4:00 am Question 1, chap 5, sect 5. part 1 of 2 10 points A child holds a sled on a frictionless, snowcovered hill, inclined at an angle of 26 . F87 N1= T = W sin = (87 N) sin 26 = 38.1383 N .Qu
University of Texas - PHY - 303K
homework 02 FONTENOT, BRIAN Due: Jan 28 2008, 4:00 am Question 1, chap 2, sect 5. part 1 of 3 10 points In deep space (no gravity), the bolt (arrow) of a crossbow accelerates at 129 m/s2 and attains a speed of 125 m/s when it leaves the bow. For ho
University of Texas - PHY - 303K
homework 03 FONTENOT, BRIAN Due: Feb 4 2008, 4:00 am Question 1, chap 3, sect 4. part 1 of 3 10 points Consider the two vectors M = (a, b) = a^+ i b ^ and N = (c, d) = c^ + d ^, where a = 4, i b = 4, c = 3, and d = -3. a and c represent the x-dis
University of Texas - PHY - 303K
homework 03 FONTENOT, BRIAN Due: Feb 4 2008, 4:00 am and Question 1, chap 3, sect 4. part 1 of 3 10 points Consider the two vectors M = (a, b) = a^+ i b ^ and N = (c, d) = c^ + d ^, where a = 4, i b = 4, c = 3, and d = -3. a and c represent the x
University of Texas - PHY - 303K
homework 07 FONTENOT, BRIAN Due: Mar 3 2008, 4:00 am Question 1, chap 8, sect 1. part 1 of 3 10 points A 3 kg block collides with a massless spring of spring constant 94 N/m attached to a wall. The speed of the block was observed to be 1.3 m/s at t
University of Texas - EE - 312
E E 312 NotesArithmetic Conversions With Floats o o Float + Double = Double Double + Int = DoubleNot With Floats o Int + int = int o Int < unsigned int < long int o Never combine unsigned ints and regular ints in expressions The value on the righ
University of Texas - EE - 312
EE 312 Notes Recursion using the stack Parameters are stored in the stack Stacks are LIFO Pushing = Adding an Item Popping = Removing an Item System Support Maintains an activation record Activation Record (Stack Frame) looks like the following o Inc
University of Texas - EE - 312
EE 312 NotesExam 2: Chapters 9.6 11-13; 15-17; 22. File Inclusion Want to include own file. Use #include "filename" Looks in local directories first Only One source file must contain a definition of main Create header files to include just your hea
University of Texas - PHY - 303K
homework 06 FONTENOT, BRIAN Due: Feb 25 2008, 4:00 am Question 1, chap 7, sect 1. part 1 of 3 10 points Assume you are on a planet similar to Earth where the acceleration of gravity g 10 m/s2 . A plane 50 m in length is inclined at an angle of 16.
University of Texas - PHY - 303K
midterm 01 FONTENOT, BRIAN Due: Feb 13 2008, 11:00 pm1Mechanics - Basic Physical ConceptsMath: Circle: 2 r, r2 ; Sphere: 4 r2 , (4/3) r3 b2 Quadratic Eq.: a x2 + b x + c = 0, x = -b 2 a-4 a cCartesian and polar coordinates: y x = r cos ,
University of Texas - EE - 312
EE312 C Coding Standards Spring 2008Writing code that is easy for others (or you later) to read is an important part of programming. Style entails a program's readability and logic structuring. Style is almost as important as correctness in program
University of Texas - EE - 312
E E 312 Discussion 1.18.2008 Most general computer Consist of a microprocessor o o o Intel x86 Takes instructions Computes a resultProgrammer o o o o o Job is to write instructions to build jobs Use programming language Our language is C Something
University of Texas - EE - 312
Dicussion Session EE 312 1/25/08Printf (" %4d", 86); Printf("%06d", 86); Printf("%4d", 10405); shows*/ Printf("%12.5e, 30.253); Control Statements: If(i>2) J = 100; Else J =-100; Can set Multiple Parameters= = = =|_|_86| |000086| |10405| /* On
University of Texas - EE - 312
C PROGRAMMING A Modern ApproachAnswers to Even-Numbered ExercisesSusan A. Cole K. N. KingW W Norton & Company New York LondonCopyright 1996 W. W. Norton & Company, Inc. All rights reserved. W. W. Norton & Company, Inc. 500 Fifth Avenue, Ne
University of Texas - EE - 312
EE 312 Programming Project #3 Flow Chart Brian Fontenot (BLF339) 15670 F: 11-12
University of Texas - EE - 312
EE 312 Programming Project #3 Flow Chart Brian Fontenot (BLF339) 15670 F: 11-12Start programdeclare variablesdeclare arrayIntialize arrayIntialize variablesprompt user informationscan for user inputread user inputsort out prime num
University of Texas - EE - 312
10 299 492 495 399 492 495 399 283 279 689 078 100 000 000 000 456 789 234 453 125 175 183 256 012 100 000 212 415 521 721 532 439 543 631 339 923 029 873 674 027 023 610 621 632 643 654 665 676 687698 609 201 805 229 429 100 100 456 789 234 453 12
University of Texas - EE - 312
EE312 Introduction to Programming I d i P iSpring 2008 Christine Julien Christine Julien Assistant Professor c.julien@mail.utexas.edu Office: ACES 5.140 Offi ACES 5 140 Office Hours: TTh: 1112:30Introductions The Teaching Team Instructor Chris
University of Texas - EE - 312
EE312 Lecture 2 Announcements Topics for today will answer the questions: Survey Results What is the C programming language ? What is C syntax ? What is C s nta ? Assignment statement Numerical expressions Numerical expressions Number stora
University of Texas - EE - 312
Micro architecture, logic circuits, and device technology -1st layer hardware vs. software Machine assembly language instruction set machine code High level programming language - c programming Not finished Need the designModels, design, and abstr
University of Texas - EE - 312
Notes 1.17 The History of C Was called NB o BCPL Orignated from the UNIX System By Denins Ritchie in Bell Labs Between 1969 and 1973 Became popular in the 1980s Original C o Called K&R C By Kernighan and Ritchie o ANSI C ANSI Standard X3.159-1989
University of Texas - EE - 312
Read Chapter 3, 7, 22 Know Chapter 2 for Quiz on FridayNotes 1.22 Floats Float single precision Double double precision Long double extreme precision Must contain decimal point or exponent By default stored as double-precision numbers F or f, L
University of Texas - EE - 312
EE 312 Notes January 24, 2008Selection o Deciding among alternative executive paths Boolean values stored in variables Tested by program Using If and Else Statements Nested and Cascaded If statements Using Switch Statements Conditional Operators
University of Texas - EE - 312
EE 312 Notes January 24, 2008Sequence Follow Sequence 1, 2, 3 Condition is True Do until false Iteration False loop back to beginSelection Condition is true go to end Condition is not true, then do functionSelection o Deciding among a