Answer to Question #204931 in C for Elaine

Question #204931

Exercise 2: Battery Model

We want to design a program to manage battery models.

(a) Define a type, BatteryModel, that represents a battery model, that is made of the known voltage , the amount of energy

it is capable of storing, and the energy it is currently storing (in joules).

(b) Define a function PowerDevice that takes as arguments: a current of an electrical device (amps), a battery of type

BatteryModel, and the time the device is to be powered by the battery (seconds), and determines whether the battery's energy reserve is adequate to power the device. If so, the function updates its reserve by subtracting the energy consumed and returns the value 1. Otherwise it returns the value 0 and leaves the energy reserve unchanged.

(c) Define a function MaxTime that takes as arguments: a current of an electrical device and a battery of type BatteryModel,

and returns the number of seconds this battery can operate the device before it is fully discharged. This function may not modify the energy reserve.






1
Expert's answer
2021-06-09T17:40:18-0400


#include <stdio.h>
struct Battery_Model{
    int voltage;
    int energy;
};
int PowerDevice(struct Battery_Model c, int t){
    if (t>50)
        return 1;
    else
        return 0;
}
int MxaTime(int c, int model){
    int t;
    return t;
}
int main()
{
    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS