Question: PLEASE ANSWER IN C LANGUAGR main.c has already shown, please answer Calculator.h and Calculator.c Given main(), create the Calculator struct that emulates basic functions of

PLEASE ANSWER IN C LANGUAGR

main.c has already shown, please answer Calculator.h and Calculator.c

Given main(), create the Calculator struct that emulates basic functions of a calculator: add, subtract, multiple, divide, and clear. The struct has one data member called value for the calculator's current value.PLEASE ANSWER IN C LANGUAGR main.c has already shown, please answer Calculator.hand Calculator.c Given main(), create the Calculator struct that emulates basic functionsof a calculator: add, subtract, multiple, divide, and clear. The struct hasone data member called value for the calculator's current value.main.c : #includemain.c :

#include

#include "Calculator.h"

int main() { Calculator calc = InitCalculator(); double num1; double num2;

scanf("%lf", &num1); scanf("%lf", &num2);

// 1. The initial value printf("%.1lf ", GetValue(calc));

// 2. The value after adding num1 calc = Add(num1, calc); printf("%.1lf ", GetValue(calc));

// 3. The value after multiplying by 3 calc = Multiply(3, calc); printf("%.1lf ", GetValue(calc));

// 4. The value after subtracting num2 calc = Subtract(num2, calc); printf("%.1lf ", GetValue(calc));

// 5. The value after dividing by 2 calc = Divide(2, calc); printf("%.1lf ", GetValue(calc));

// 6. The value after calling the Clear() method calc = Clear(calc); printf("%.1lf ", GetValue(calc));

return 0; }

7.7 LAB 1-3: Calculator Given main(), create the Calculator struct that emulates basic functions of a calculator: add, subtract, multiple, divide, and clear. The struct has one data member called value for the calculator's current value. Implement the Calculator struct and related function declarations in Calculator.h, and implement the related function definitions in Calculator.c as listed below: - InitCalculator(Calculator c) - initialize the data member to 0.0 - Calculator Add(double val, Calculator c) - add the parameter to the data member - Calculator Subtract(double val, Calculator c) - subtract the parameter from the data member - Calculator Multiply(double val, Calculator c) - multiply the data member by the parameter - Calculator Divide(double val, Calculator c) - divide the data member by the parameter - Calculator Clear(Calculator c ) - set the data member to 0.0 - double GetValue(Calculator c) - return the data member Given two double input values num1 and num2, the program outputs the following values: 1. The initial value of the data member, value 2. The value after adding num1 3. The value after multiplying by 3 4. The value after subtracting num2 5. The value after dividing by 2 6. The value after calling the clear() method Ex: If the input is: 10.05.0 the output is: Current file: Calculator.c Load default template... Current file: Calculator.h Load default template... 1 2 // TODO: Define the Calculator_struct 3 4 // TODO: Declare functions 5 // InitCalculator(), Add(), Subtract(), Multiply(), Divide(), Clear(), Getvalue() 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!