129k views
2 votes
Write a MATLAB or C (your choice) program that prompts the user to enter the number of series components in a system and the MTBFs for each component and then calculates the overall MTBF for the system using a FOR or a WHILE structure (loop). To test your program, determine the MTBF for a radar system consisting of an antenna subsystem with an MTBF of 2000 hours, a transmitter with an MTBF of 800 hours, a receiver with an MTBF of 3000 hours, and a computer with an MTBF of 5000 hours. Make sure that you send the .m or .cpp file to the drop box and include units.

User Stevebot
by
5.2k points

1 Answer

3 votes

Answer:

C++ programming language (code) was used or applied in prompting a user to enter he number of series components in a system and the MTBFs for each component and then calculates the overall MTBF for the system using a FOR or a WHILE structure (loop).

Step-by-step explanation:

Solution

THE CODE

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

int key;

// do while loop to run the program up to user wants to quit "to quit enter any number except 1 "

do

{

int n,i=0,mtbf[100]; //declaring array to store the mtbf values of the n components

float result=0,result1;

cout<<"\\ Enter number of components";

cin>>n;

while(i<n) // reading mtbf values into the array

{

cout<<"\\ Enter MTBF(Mean time between failure)==>";

cin>>mtbf[i];

i++;

}

i=0;

while(i<n) //in this while loop first i calculate the denominator part i.e (1/mtbf[i])+(1/mtbf[i])...

{

result+=(1.0/mtbf[i]);

i++;

}

result1=1/result; //this value calculate the total MTBF of the system

cout<<"\\ The MTBF of SYSTEM is\t"<<result1;

cout<<"\\ Another system to check? enter 1 for yes";

cin>>key;

}while(key==1);

}

User Igor Be
by
5.1k points