So, I've just started learning to program (I'm taking Intro to Programming) and I'm stuck on a question. I have to write a program that will solve for the voltage through a resistor for every value of temperature between 0 and 100, and print out the voltage for every temperature value that is a multiple of 10. The question reads as follows:
The resistor R represents a temperature sensor enclosed in the beaker. The resistance R, in
Ω, is related to the temperature T, in °C, by the equation
r=r
0+kt
where R
0 = 50 and k = 0.5.
The voltmeter displays the value of the voltage across the sensor
v
m=r*v
s/(r
s+r)
The voltage vm indicates the temperature, T, of the water according to the equation
t=150*v
m/(20-v
m)-100
Write a C++ program that prints a table showing the meter voltage corresponding to
water temperatures varying from 0 °C to 100 °C in increments of 10 degrees.
So far I've done this:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
double r, rnot=50, k=0.5, vs=20, rs=75, vm, t=0;
r=rnot+k*t;
vm=r*vs/(rs+r);
t=150*vm/(20-vm)-100;
do {
if (t==0 || t==10 || t==20 || t==30 || t==40 || t==50 || t==60 || t==70 || t==80 || t==90 || t==100)
cout<<"When t is "<<t*10<<"The voltage of the meter is "<<vm<<"."<<endl;
t++;
} while t<=10
}
I tried incrementing t nine more times in order to insure it reaches 10, but that gave me the same error compiling; syntax error: identifier "t."