Homework3
pdf
keyboard_arrow_up
School
University Of Arizona *
*We aren’t endorsed by this school
Course
175
Subject
English
Date
Jan 9, 2024
Type
Pages
2
Uploaded by ProfFlower11130
ECE175 Computer Programming for Engineering Applications Homework Assignment 3 Due Date: Tuesday September 23, 2014 11:59 PM, via D2L Conventions
: Name your C programs as hw
x
p
y
.c
where x
corresponds to the homework number and y corresponds to the problem number. Submission Instructions: Submit your .c files named hw3p
1
a.c, hw3p
1
b.c, and hw3p2.c
via D2L Dropbox. Write comments to your programs
. Programs with no comments will receive PARTIAL credit. For each program that you turn in, at least the following information should be included - Author: - Date created: - Brief description of the program: Problem 1
: In a certain building at a top secret research lab, some yttrium-90 has leaked into the computer analysts’ coffee room. The half-life of the substance is about 3 days
; that is, the radiation level is only half of what it was 3 days ago. The safe level of the radiation is at most 0.9 millirem a day.
a)
Your program should ask the user to enter the initial amount of radiation and then displays the chart (table format) of the radiation level every 3 days for the total of 21 days with the message Unsafe
or Safe
after every time. See sample execution #1 and #2. b)
Your program should ask the user to enter the initial amount of radiation and then displays a chart (table format) of the radiation level every 3 days with the message Unsafe
or
Safe
after every time and the chart/table should stop just before the radiation level is one-tenth of the safe level (0.1 of the safe level (0.9 millirem)), because the more cautious analysts will require a safety factor of 10. See sample execution #3 and #4. Note: To get full score for this problem 1.
You are not to use the math library. 2.
From a) and b) above, one of them is a counting loop and the other is a conditional loop. Use the for loop
statement for the counting loop
and the while loop
statement for the conditional loop
. 3.
The chart/table displayed from your code should be very similar to sample execution #1-4. Submit your .c file named hw3p
1
a.c and
hw3p
1
b.c in
the HW3 Dropbox on D2L Test cases:
a)
150, 18, 50, 0 b)
150, 25.4, 18, 0
Below are sample execution for Part b) of Problem
1
Problem 2:
Number-to-text translator. You are asked to implement an automated number-to-
text translation system. Write a C program that receives an integer number (up to 9 digits) and converts each digit to the appropriate text word. Assume that no number starts with a zero
. Sample execution: Please enter your number (up to 9-digit):90543 nine zero five four three
Sample execution: Please enter your number (up to 9-digit):800769124 eight zero zero seven six nine one two four Sample execution: Please enter your number (up to 9-digit):1234567890 your entered number has more than 9 digits Test cases: 85704, 115328769, 1234567890, 90 Hint: Use a loop structure to count the number of digits of the number entered by the user. Consider repeated division of the entered number by 10 in order to isolate each digit from left to right. Then use a switch statement to convert a digit to a word. Submit your .c files named hw3p1a.c, hw3p1b.c, and hw3p2.c
via D2L Dropbox Sample execution #1 (for part a)
Enter an initial amount of radiation (millirems/day) >150 Day Radiation(Status) 0 150.0000(Unsafe) 3 75.0000(Unsafe) 6 37.5000(Unsafe) 9 18.7500(Unsafe) 12 9.3750(Unsafe) 15 4.6875(Unsafe) 18 2.3438(Unsafe) 21 1.1719(Unsafe) Sample execution #2 (for part a)
Enter an initial amount of radiation (millirems/day) >18 Day Radiation(Status) 0 18.0000(Unsafe) 3 9.0000(Unsafe) 6 4.5000(Unsafe) 9 2.2500(Unsafe) 12 1.1250(Unsafe) 15 0.5625(Safe) 18 0.2813(Safe) 21 0.1406(Safe) Sample execution #3 (for part b) Enter an initial amount of radiation (millirems/day) >150 Day Radiation(Status) 0 150.0000(Unsafe) 3 75.0000(Unsafe) 6 37.5000(Unsafe) 9 18.7500(Unsafe) 12 9.3750(Unsafe) 15 4.6875(Unsafe) 18 2.3438(Unsafe) 21 1.1719(Unsafe) 24 0.5859(Safe) 27 0.2930(Safe) 30 0.1465(Safe) Sample execution #4 (for part b) Enter an initial amount of radiation (millirems/day) >25.4 Day Radiation(Status) 0 25.4000(Unsafe) 3 12.7000(Unsafe) 6 6.3500(Unsafe) 9 3.1750(Unsafe) 12 1.5875(Unsafe) 15 0.7937(Safe) 18 0.3969(Safe) 21 0.1984(Safe) 24 0.0992(Safe)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help