lab3 - cin >> speed...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <cstdlib> #include <iostream> #include <string> # using namespace std; u int main(){ int n, speed, hour, prevTime, interval=0, total=0; cin >> n ; prevTime=0; while (n != -1){ for (int i= 0; i < n; i++){
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cin &gt;&gt; speed &gt;&gt; hour; interval= (speed*(hour-prevTime)); prevTime=hour; total =interval + total; } cout &lt;&lt; total &lt;&lt; &quot; miles&quot; &lt;&lt; endl; cin &gt;&gt; n ; } }...
View Full Document

Ask a homework question - tutors are online