Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that calculates the distance a car travels based on the time (length of travel in hours) and speed(mph in miles) generated randomly

image text in transcribed
Write a program that calculates the distance a car travels based on the time (length of travel in hours) and speed(mph in miles) generated randomly with the rand() function. This program should use the parallel arrays in the main function provided and follow the specifications a-d below. const int SIZE = 5; int main() { int time (SIZE); int speed[SIZE]: int distance (SIZE); loadArrays (time, speed); calculateDist(time, speed, distance); print (time, speed, distance); 1 a) Write a function that will generate 5 integers for time array and 5 integers for the speed array. The random numbers for time are ranging [1-6] (reads 1 to 6 inclusively). The random numbers for speed are ranging [50-70] (reads 50 mph to 70 mph inclusively). b) Write a function that will calculate the distance from the values in the time and speed arrays and place the answer in the distance array. The calculation is as the following: distance Value = time Value * speedValue. c) Write a function that will print out the input data from a) and the calculated items from b) above (print the data (randomly generated to the screen, and the calculated distance values in the format of 3 items on one line.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions