Question

In: Computer Science

Mr. Rashid plans to purchase the electronics itemsbased on his budget. So he needs a...

Mr. Rashid plans to purchase the electronics items based on his budget. So he needs a purchase planner which will help to calculate the price of electronics items, he can purchase based on the available amount. If Mr. Rashid enters his budget amount and chooses the numbers of electronic items from the list of available electronic items, the purchase planner will calculate the cost of electronics items based on the number of items selected, the total cost of all the selected electronic items and also the balance amount.

Display the list of electronic items and its price as follows,
==============================================
1. HP Laptop --------------------200 OMR
2. Samsung Mobile S10--------225 OMR
3. Apple 10s----------------------350 OMR


Solutions

Expert Solution

  • Code:-

#include
/* Here, we are defining a user defined structure to hold the data related to electronic item together */
typedef struct elec_item { char *name; int cost; }EItem;
int main() {
   EItem items[3]; int budget,ch; // defining the items
//Here, you can take the inputs and define the items in a for loop
items[0].name = "HP Laptop"; items[0].cost = 200;
items[1].name = "Samsumg Mobile S10"; items[1].cost = 225;
items[2].name = "Apple 10s"; items[2].cost = 350;
printf ("Enter Budget Amount: "); scanf ("%d", &budget); //reading the budget from user
/* displaying the menu */
printf ("==============================================================\n");
printf ("1. %s --------------------- %d\n", items[0].name, items[0].cost);
printf ("2. %s --------------------- %d\n", items[1].name, items[1].cost);
printf ("3. %s --------------------- %d\n", items[2].name, items[2].cost);
printf ("==============================================================\n");
printf ("Enter choice:"); // scanning the choice of user
scanf ("%d", &ch);
// verifying the user choice and printing a message if wrong choice
if (ch < 3 && ch > 0) { int quantity, total_cost;
// By taking other user inputs and caluculating the cost
printf ("How many %s: ", items[ch-1].name);
scanf ("%d", &quantity);
if ((total_cost = quantity * (items[ch-1].cost)) <= budget) {
    printf ("\tCost of 1 %s is %d\n", items[ch-1].name, items[ch-1].cost);
    printf ("\tTotal Cost = %d\n", total_cost);
    printf ("\tBalence Amount = %d\n", budget - total_cost); }
    else {
       printf ("\tThis will exceed your budget limit\n");
    }
    }
    else {
    printf ("\tThat's a wrong choice\n");
    }
    return 0;
    }

  • Output:-


Related Solutions

Mr. Ambitious is celebrating his 30th birthday today. He plans to retire shortly after his 50th...
Mr. Ambitious is celebrating his 30th birthday today. He plans to retire shortly after his 50th birthday and estimates that he can live comfortably off a pension of $50,000 per year, paid annually for 40 years starting with his 51st birthday. He reckons that in order to achieve this, he only needs to invest $50,000 into his retirement fund every two years until he retires. The first investment will be made on his 32nd birthday and the last on his...
Mr. S. P. Johnson is creating a college fund for his daughter. He plans to make...
Mr. S. P. Johnson is creating a college fund for his daughter. He plans to make 7-yearly payments of $10,000 each with the first payment deposited today on his daughter’s 6th birthday (happy birthday!) Assuming his daughter will need three equal withdrawals from this account to pay for her law-school education beginning when she is twenty-two (i.e. 22, 23, 24), how much will she have on a yearly basis for her law school career? Mr. Johnson expects to earn a...
Mr Kaur started a software business. He decided to incorporate. He did so, calling his company...
Mr Kaur started a software business. He decided to incorporate. He did so, calling his company Kaur and Sons Pty Ltd. Mr Kaur sold the assets and goodwill of his software business to Kaur and Sons Pty Ltd for $30,000. Rather than the company paying him $20,000 in cash, the company issued 20,000 shares worth $1.00 each to Mr Kaur. At the time of the sale, the company still owes $10,000 to Mr Kaur. This debt relates to $10,000 of...
James moved to a new house so he rented his old home to Mr. Parker for...
James moved to a new house so he rented his old home to Mr. Parker for two years. Later the old house caught fire and had a $100,000 loss. The old house was valued at $400,000 and James had a $300,000 homeowner's insurance policy with an 80% coinsurance. How much will insurance company pay for his loss?
Graham plans to save $100 each month for the next 20 years so he can purchase...
Graham plans to save $100 each month for the next 20 years so he can purchase a boat. If he earns 10% interest annually with monthly compounding, how much money will he have at the end of 20 years if he starts saving today?
An employer earning $160,000 is considering establishing multiple retirement plans for his organization so he can...
An employer earning $160,000 is considering establishing multiple retirement plans for his organization so he can save more for retirement. Which combination would allow for the largest contribution? 401(k) plan and SIMPLE 401(k) plan Private 457(b) plan and 403(b) plan SIMPLE IRA plan and SEP IRA plan 401(k) plan and 403(b) plan
MR GREG WANTS TO PURCHASE HIS DREAM HOUSE WHICH WILL COST 600000 IN 15 YEARS. HE...
MR GREG WANTS TO PURCHASE HIS DREAM HOUSE WHICH WILL COST 600000 IN 15 YEARS. HE IS GOING TO PUT 40000 EACH YEAR FOR TEN YEARS TOWARDS THIS. AT WHAT INTEREST RATE MUST HE INVEST HIS MONEY TO ACHIEVE HIS GOAL. SOLVE THE QUESTION AND DRAW THE CASH FLOW DIAGRAM
Austin needs to purchase a new heating/cooling system for his home. He is thinking about having...
Austin needs to purchase a new heating/cooling system for his home. He is thinking about having a geothermal system installed, but he wants to know how long it will take to recoup the additional cost of the system. The geothermal system will cost $20,500. A conventional system will cost $6,000. Austin is eligible for a 30% tax credit to be applied immediately to the purchase only if he chooses the geothermal system. He estimates that he will save $1,500 per...
Fred has budgeted $21 for a restaurant supper. He has a big appetite, so his budget...
Fred has budgeted $21 for a restaurant supper. He has a big appetite, so his budget is the only limit to how much he can order. The restaurant sells only steak ($21 each) or hamburger ($7 each). Fred is equally happy with 2 hamburgers or 1 steak. Please answer the 4 questions below, in order: 1) What is Fred's marginal rate of substitution of steak for hamburger? (Express as one number with one decimal place.) 2) At Fred's point of...
Mr. Ali decided to set-up his own business of Shoe making. He needs raw materials, building,...
Mr. Ali decided to set-up his own business of Shoe making. He needs raw materials, building, equipment and machinery, and finance to meet up overhead expenses. He wants interest (Riba) free financing. How Islamic Banking can help him in this situation to meet his working capital needs? 1. Take any Islamic Bank working in Pakistan. 2. Explain what Islamic Financing products are available to help Ali? 3. In case, Ali needs long term financing then how Islamic bank can help...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT