Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a MIPS assembly language program that computes the total amount that a customer needs to pay when purchasing T-shirts. The program needs to read

Write a MIPS assembly language program that computes the total amount that a customer needs to pay when purchasing T-shirts. The program needs to read in a number of T-shirts and asks a user to enter 1 if they have a discount coupon. If a user enters a number of T-shirts that is less or equals to 0, then the program needs to print out the message Invalid Number of T-shirts. and exits. If a user enters a number of T-shirts between 1 and 49, then each T-shirt costs $7 each. If a number of T-shirts is between 50 and 99, then each T-shirt costs $6 each. If a number of T-shirts is 100 or greater than 100, then each T-shirt costs $5 each. If a user has a discount coupon, they gets a discount of $5. The program needs to compute each users total payment amount and to print it out.

image text in transcribed

image text in transcribed

int howMany; int discount; int payment = 0; printf("How many T-shirts would you like to order? "); //read an integer from a user input and store it in howMany scanf("%d", &howMany); if (howMany = 50) { payment = howMany*6; } else { payment = howMany 5; } printf("Do you have a discount coupon? Enter 1 for yes. (any other integer will indicate no discount) "); //read an integer from a user input and store it in discount scanf("%d", &discount); if (discount == 1) { payment = payment - 5; } //print out the payment printf("Your total payment is $%d ", payment); } //end of else Here is a sample output (user input is in bold): How many T-shirts would you like to order? 43 Do you have a discount coupon? Enter 1 for yes. (any other integer will indicate no discount) 0 Your total payment is $301 Here is another sample output (user input is in bold): How many T-shirts would you like to order? 67 Do you have a discount coupon? Enter 1 for yes. (any other integer will indicate no discount) 1 Your total payment is $397 Here is another sample output (user input is in bold): How many T-shirts would you like to order? 133 Do you have a discount coupon? Enter 1 for yes. (any other integer will indicate no discount) 1 Your total payment is $660 Here is another sample output (user input is in bold): How many T-shirts would you like to order? -5 Invalid Number of T-shirts

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions

Question

What tools might be helpful?

Answered: 1 week ago