dcu
 

This is DCU forum. You can create topics and participate in their discussion.

Add to Favorites Send us an e-mail
Interesting websites
Subscription
Visitors
Calendar
Top commentators
Other sites
Most commented entries
Back to homedcu / Forum / Software Engineering / Problem Sets for EE102

Problem Sets for EE102

Create topicCreate topic | To list

Posted byText

dcu Send a message
dcu dcu
Problem Sets for EE102
2379 days ago 21.11.2005 18:47:15 Quote('4732','4732','6','15')">Report spam

In case someone needs the Problem Sets 1,2,3 for Software Engineering, (Going to update this with each new Problem set)

SET1:

Problem 1.1: Write a program to calculate the hypotenuse of a right-angled triangle, where the lengths a and b of the triangle are 3 & 4 respectively. The program should calculate the length c of the hypotenuse given the formula: c=sqrt(a^2+b^2). Print the value of c to the screen. Redo the problem by reading values for a and b. (*)

Problem 1.2: Write a program which takes the values of three resistors (r1=2000 ohms, r2=1500 ohms and r3=750 ohms) and calculates their total resistance rp when arranged in parallel and rs when arranged in series. rp is given by rp=1/(1/r1+1/r2+1/r3) and rs is given by rs=r1+r2+r3. (**)

Problem 1.3: Write a program to calculate how tall is a building. To measure how tall is the building you go to the top floor and leave a stone to fall to the ground, while measuring the time it takes to reach the ground level. To increase the precision of your experiment you do this three times and take three readings of the time: t1, t2 and and t3, expressed in seconds. Calculate the height h given the equation h=1/2(g.t^2) where g=9.81 m/s for Dublin and t is the average time. The program should print the result expressed in meters. Test the program. (***)

Problem 1.4: Write a program which reads three values a, b and c that are the coefficients of a quadratic equation ax^2+bx+c = 0. Calculate the roots of the equation after you verify that (b^2-4ac) is positive. What is the other condition you have to test for such as you can calculate the roots? The roots are given by r = (-b ± sqrt(b^2-4ac))/2a. Print either the roots or a message of error if you cannot calculate the roots. Test the program. Note: you need to add the precompiler directive #include at the start of your program to use the function sqrt(). (****)

Problem 1.5: Write a program that calculates the perimeter and the area of a rectangle. The program should read three pairs of integers (x1,y1), (x2, y2) and (x3,y3) which represent three points of the rectangle. The program should display the perimeter and the area values in easily readable form. Use the Euclidean distance between the points: distance(Point0, Point1)=sqrt[(x0-x1)^2+(y0-y1)^2]. Test the program. Note: you need to add the precompiler directive #include at the start of your program to use the function sqrt(). (*****)

SET2:

Problem 2.1: Write a program to calculate the cost of fencing a circular field. The program should read in two integers, d for the diameter of the field in meters and c for the cost of a twenty-meter roll of sheepwire. pi=3.1416. The program should print in an easily readable form the number of rolls of sheepwire needed for the job and the cost of fencing the circular field.

Problem 2.2: Write a program which reads in the lengths in meters of the sides of a triangle l, m and n, calculate the perimeter and area of the triangle and determines the number of 2 litre tins of paint required to paint the area. A 2-litre paint can cover 20 square metres. The program should print in an easily readable form the number of tins requires.

Problem 2.3: Write a program to calculate the maturity value of a short-term loan at 20, 40 and 60 days. The program should read in two values, i.e. the amount of the principal value of the loan in Euro (p) and the percentage annual interest rate (i). The maturity value v is given by v=p(1+i/100*n/365) where n is the number of days. The program should print the maturity value in Euro and punts for 20, 40and 60 days.

Problem 2.4: Write a program to calculate the cost of making a copper cylinder. The program should read in the radius of the cylinder, r, the height of the cylinder, h and the cost in Euro per square centimetres of copper sheeting, c. Assume that there is no wastage in the manufacturing process. The program should calculate the area of copper sheeting needed for the two circular ends of the cylinder and add the area needed for the body of the cylinder. pi=3.1416. The program should print in an easily readable form the cost of the copper cylinder in Euro and punts. (solution)

Problem 2.5: Write a program to calculate the cost of a circular steel plate, which has to be cut from a square piece of steel. The diameter of the circle is equal to the side of the square. The program should read in the radius of the circle, r and the cost per square centimetre of steel plate in Euro, c. The square steel plate is purchased at cost c and the wastage can be returned to the supplier for 20% of the cost c for melting down. pi=3.1415. The program should print in a easily readable form the cost of the circular steel plate.

SET3

Problem 3.1: Write a program that uses a loop to display the numbers from a=1 to b=10, together with the square and cube of each of their values. Redo the problem by reading values for a and b. (*)

Problem 3.2: Write a program to display a multiplication table, such as young children use. The program reads a value n and then displays the results in a table like the one exemplified below for n=4. Test the program. (**)

1 2 3 4

1 1 2 3 4

2 2 4 6 8

3 3 6 9 12

4 4 8 12 16


Problem 3.3: Write a program to calculate the Fibonacci series of numbers, given the length of the series. The first two numbers in the series are 1 and 1. Following these, each number of the series is calculated as the sum of the previous two numbers. The program should read n – as the length of the series and to display the first n numbers from the Fibonacci series. Test the program. (***)

Problem 3.4: Write a program to read two numbers n and s. The programs should verify that n divides exactly by s. Then the program should display all the verses of the following nursery rhyme, starting from number n that decreases with step s: n green bottles, hanging on a wall, n green bottles, hanging on a wall, If s green bottles were to accidentally fall, There’d be n-s green bottles hanging on the wall. (****)

Problem 1.5: Write a program that implements a hand calculator with the following buttons: ‘+’, ‘-‘, ‘*’, ‘/’, ‘C’, ‘=’. It is supposed to repeatedly read float values, interleaved by characters (like somebody would have pressed one of the calculator’s buttons). The program should either reac another operand or display the result of that operation. Test the program. (*****)


SET4

Instructions: Write C programs as specified in the question. Remember the approach to problem solving: outline the solution first (flow chart), then code the program.

Problem 4.1: Write a program that reads in four integers a,b,c and d and then determines which is the biggest. Print the value of the biggest with an appropriate message. (*)

Problem 4.2: Write a program to read in the sides of a triangle (l,m,n) and determine if it is a right angled triangle or not. If it is a right-angled triangle, then Pythagorus's theorem will hold for it. The program should display an appropriate message. Ask the user if s/he does not want to check another triangle and while so, repeat the procedure. (**)

Problem 4.3: Write a program to read in three integers (1-100) and sort them in descending order. The program should print the values in descending order with appropriate messages. Repeat the problem while the user wants to. (***)

Problem 4.4: Write a program to read in any date in format: day, month, year. The day must be from 1 to 31, month from 1 to 12 and year must be a number from AD 1800 onwards. Determine whether the year is a leap year and print appropriate messages. If year is before 1800 or greater than 9999, print "out of range" message. A leap year is defined as a centenary year divisible by 400 or a non-centenary year divisible by 4. Check if the day number corresponds to the maximum number accepted in that month, that year (E.g. 28 or 29 in February, 30 in November, etc.), otherwise print an error message. (****)

Problem 4.5: Write a program to calculate the commission for a sales department and print the commission in an easily readable form. The program should read in the sales figure as a real number and compute the commission as follows: - On sales of up to 10000 Euro, a commission of 5% is paid. - On sales over 10000 Euro and up to 20000 Euro, an additional 5% is paid on the amount exceeding 10000. - On sales over 20000 an additional 0.25% is paid on the amount exceeding 20000 Euro. Provide a menu that would allow you to recompute the commission, to enter a new sales figure, or to quit. (*****)




Comments: 1 Views: 121822

Anonymous
2361 days ago 09.12.2005 19:20:45 Quote('4732','88','6','18')">Report spam

Who is active on the site?
Abuse | Hosted by MyLivePage | | Design by Next Step | © Kolobok smiles, Aiwan