Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write the coding clearly.I need to understand how to solve this question.

ID: 3875422 • Letter: P

Question

Please write the coding clearly.I need to understand how to solve this question.

QUESTION 2 WashNDry is a self-service laundry mart. The laundry machine operates using 50 cent coins. There are two types of laundry machines and dryers charges for each type of machine. The following tables show the Laundry machine Charge(RM)- 4.50 10 kg maximum capacity 15 kg maximum capacity 6.00 Charge (RM) 3.50 4.00 Dryer 10 kg maximum capacity 15 kg maximum capacity A customer may use more than one machine. For example: If the customer uses: 10 kg maximum capacity - 2 laundry machine 15 kg maximum capacity -1 laundry machines 10 kg maximum capacity-1 dryer The charges would be: 2 * 4.50 + 1 * 6.00 + 1 * 3.50 = RM18.5 Therefore, 37 pieces of 50 cent coins are needed by this customer Based on the information: a) Write a function named int calccoins1 (int,int,int,int) that receives the number of laundry machine and dryer used by the customer. The function will determine how many pieces of 50 cents coins a customer needs to do the laundry 6 marks) b) Write a function named int calccoins2 (int,int) that receives number of detergent and softener. The function will calculate the number of 50 cents coins (4 marks) needed for the laundry detergent and the softener if the cost is RM1.00 each.

Explanation / Answer

Hello there,

I am writing the complete code in C language, which is very clear written, in which first function as mentioned, is calculating the number of coins for machines and dryers and second function is calculating coins for detergent and softner,

Here is the code:

#include <stdio.h>

int calcCoins1(int, int ,int, int );

int calcCoins2(int, int );

void main () {

int total,m1,m2,d1,d2,dt,sf;

printf("Enter the number of 10 kg laundry machines used : ");

scanf("%d ", &m1);

printf("Enter the number of 15 kg laundry machines used : ");

scanf("%d ", &m2);

printf("Enter the number of 10 kg dryer used : ");

scanf("%d ", &d1);

printf("Enter the number of 15 kg dryer used : ");

scanf("%d ", &d2);

printf("Enter the number of detergent : ");

scanf("%d ", &dt);

printf("Enter the number of softner used : ");

scanf("%d ", &sf);

/* calling both the functions to get number of 50 cent coins */

total = calcCoins1(m1,m2,d1,d2) + calcCoins2(dt,sf);

printf( "the total number of 50 cent coins needed : %d ", total );

}

/* function calculating the coins for laundry machine and dryer */

int calcCoins1(int m1, int m2, int d1, int d2) {

/* local variable declaration */

double mt1,mt2,dt1,dt2;

int result;

if (m1)

mt1 = m1*(4.50);

if (m2)

mt2 = m2*(6.00);

if (d1)

dt1 = d1*(3.50);

if (d2)

dt2 = d2*(4.00);

  

result = (mt1+mt2+dt1+dt2)/0.50;

return result;

}

/* function calculating the coins for detergent and softner */

int calcCoins2(int dt, int sf) {

/* local variable declaration */

double dt1,sf1;

int result;

if (dt)

dt1 = dt*(1.00);

if (sf)

sf1 = sf*(1.00);

  

result = (dt1+sf1)/0.50;

return result;

}

Hope,you got the solution, if you feel any doubt , feel free to ask.

Thank you