Professional Documents
Culture Documents
LA2
LA2
1. Name the .c file with your ID_your name. Mention your name, your section, your ID
as comments on top of the code.
2. Strictly, the submission file type should be .c file.
3. Assessment submission deadline is 7/4/2022 @23:59. A delay in assessment
submission will result in the following grade deduction
· Delay of 1 Day : 40% Deduction
· Delay of 2 Days: 60% Deduction
· Delay of 3 Days: 100% Deduction
4. In case of plagiarized submission, student will receive a notification email with the
below penalty applied starting the date of the email:
· Resubmission on the first day (within 24 hours after notification): 40% deduction
· Resubmission on the second day after notification: 60% deduction.
· Failing to resubmit within two days after notification, the assessment will be
graded with zero.
5. Please check Banner for your Gradebook and Attendance.
6. AUM rules and regulations apply.
Problem
Write a C program that implements the following parts. The program should run successfully
with different scenarios. In the program, constant statements and global variables cannot be
used. You should write code based on the covered material; It is not allowed to include
statements that are not covered in the lab until the end of week 6. The program should
perform the following:
A. Define a string variable A_YourName (example: A_Ahmed) of size equal to the sum of digits
of your AUM ID. Note that the name of the string variable should include your name. For
example, if your AUM ID number is 42357 and your name is “Ahmed”, the size of the variable
A_Ahmed is 21 (4+2+3+5+7 = 21). Expressions are not allowed to be used to calculate size.
Initialize the string with your name. Print the following on the screen: Lab 2 followed by the
value of string A_YourName, your AUM ID number and your section number. For example,
if your section number = F2 and ID = 42357, the program should print: (5 points)
Lab 2 is created by student xxx yyy - ID = 42357- section F2
B. Define two integers A_YourAUMID and B_YourAUMID (example: A_42357), and initializes
them with the first and second digits of your AUM ID, respectively. If your ID is 42357, the
value of the variable A_42357 will be 4 and the value of variable B_42357will be 2. (5 points)
C. Define an integer variable C_YourName (example: C_Ahmed) and initialize it with the largest
of the two numbers A_YourAUMID and B_YourAUMID using switch statement. Note that
the name of the string variable should include your name. For example, if your ID is 42357
and your name is “Ahmed”, the value of A_42357 is 4 and the value of B_42357 is 2, the
value of C_ Ahmed will be 4. Using other variables, if and if else statements are not allowed
in this part. (15 points)
D. Prompt the user to enter the price of C_YourName items. For example, if the value of
C_YourName is 4, then you have to prompt the user to enter price of 4 items. The program
should print the price of each item after discount as shown in the sample output. Then, it
prints the total price after discount of all items which got a discount of 20%. Using else is
not allowed in this part. (20 points)
Item Discount
Price < 1000 10%
1000 <= Price <=2000 20%
Price > 2000 15%
You should use the loop type based on the following table:
Student AUM ID Loop type
Less than 50000 for
Between 50000 and 60000 do while
above 60000 while
Page 2 of 3
E. Define an integer variable E_YourName (example: E_Ahmed), and initialize it with the
highest digit of your AUM. Using the correct loop type, print output as per the following
rules:
Page 3 of 3