Question

In: Computer Science

can someone change this code so that timestandard can be calculated at the end of the...

can someone change this code so that timestandard can be calculated at the end of the code using the inputs n,RF,PFD, and the measured cycles, instead of being called from the beginning of the code

using namespace std;

float timestandard(float time, float rf, float pfd)

{

return((time / 100) * rf * (1 + pfd)); /* calculating the time standard using the given formula*/

}

int main()

{

int n, rf, pfd, x;


/* inputs are taken*/


cout << "**** Welcome to the Time Study Program ****";

cout << "\nEnter the number of operations for the given operation being performed";

cout << "\nNumber of elements:";

cin >> n; // Input for # elements

cout << "\n\nEnter the Performance Rating<PR> factor as a percentage";

cout << "\nRF:";

cin >> rf; // Input for PR

cout << "\n\nEnter the Personal Fatigue Delay<PFD> value as a percentage";

cout << "\nPFD:";

cin >> pfd; // Input for PFD

cout << "\n\nNow enter the measured cycle times in hundreths of a minute for each element";

for (int i = 0;i < n;i++) // Input for each measured cycle

{

cout << "\nElement " << i + 1 << ": ";

cin >> x;

}

/*rest of the calculation and function calling is done here*/

float r = (float)rf / 100;

float p = (float)pfd / 100;

cout << "\n\n**** Time Study Results ****";

cout << "\nThe Time Standard is: Ts = " << timestandard(x, r, p) << " minutes";

return 0;

}

Solutions

Expert Solution

#include <iostream>
using namespace std;

int main()
{
int n, i = 0;
float RF, PFD, Tn = 0, Ts;
cout << "**** Welcome to the Time Study Program ****" << endl;
cout << "\nEnter the number of elements for the given operation being performed" << endl;
cout << "Number of Elements: ";
cin >> n;
if (n < 0)
{
cout << "\nNumber of elements cannot be negative! Try again.";
return 0;
}

cout << "\nEnter the Performance Rating (PR) factor as a percentage" << endl;
cout << "RF: ";
cin >> RF;
if (RF < 0)
{
cout << "\nPercentage cannot be negative! Try again.";
return 0;
}
RF = RF / 100.0;

cout << "\nEnter the Personal Fatigue Delay (PFD) value as a percentage" << endl;
cout << "PFD: ";
cin >> PFD;
if (PFD < 0)
{
cout << "\nPercentage cannot be negative! Try again.";
return 0;
}
PFD = PFD / 100.0;

cout << "\nNow enter the measured cycle times in hundredths of a minute for each element" << endl;
cout << "(Note: Time entered should be relative not absolute)\n";

float ET[n], temp[n];
while (i < n)
{
cout << "\n Element " << i + 1 << ": ";
cin >> ET[i];

if (ET[i] < 0)
{
cout << "\nTime cannot be negative! Try Again.";
return 0;
}
i++;
}

/*
temp[] array stores the one hundredths of minutes of corresponding elements
*/

i = 0;
while (i < n)
{
if (i == 0)
temp[i] = ET[i] / 100;
else
temp[i] = (ET[i] - ET[i - 1]) / 100;
i++;
}

i = 0;
while (i < n)
{
Tn = Tn + temp[i];
i++;
}

Tn = Tn * RF;
Ts = Tn * (1 + PFD);

cout << "\n**** Time Study Results ****";
cout << "\nThe Time Standard is: Ts = " << Ts << " minutes";
return 0;
}


Related Solutions

can someone translate this pseudo code to actual c++ code while (not the end of the...
can someone translate this pseudo code to actual c++ code while (not the end of the input) If the next input is a number read it and push it on the stack else If the next input is an operator, read it pop 2 operands off of the stack apply the operator push the result onto the stack When you reach the end of the input: if there is one number on the stack, print it else error
Can someone create a Test bench for this 4 Bit USR code so that it can...
Can someone create a Test bench for this 4 Bit USR code so that it can shift left, shift right and Load. This is in VHDL. Please type out the code. library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity Uni_reg is port( LR,SP,clk,clear,shL,shR: in std_logic; -- shL = shift left shR= shift right Da,Db,Dc : in std_logic; --inputs for load Qa,Qb,Qc : out std_logic); --out puts from the flipflops end Uni_reg; architecture Structural of Uni_reg is signal lr1,lr2,sp1,sp2,R1,R2,R3 : std_logic; signal L1,L2,L3,LOAD1,LOAD2,LOAD3:std_logic; signal...
Can someone fix this code so that it can count comparison and exchange? import java.util.Arrays; class...
Can someone fix this code so that it can count comparison and exchange? import java.util.Arrays; class Main { static int comparisons; static int exchanges; // Recursive function to perform insertion sort on sub-array arr[i..n] public static void insertionSort(int[] arr, int i, int n) { int value = arr[i]; int j = i; // Find index j within the sorted subset arr[0..i-1] // where element arr[i] belongs while (j > 0 && arr[j - 1] > value) { arr[j] = arr[j...
How to validate Javascript form data? Here is the code. Can someone modify it so that...
How to validate Javascript form data? Here is the code. Can someone modify it so that all the information is validated? Thanks. <!DOCTYPE html> <html lang="en"> <head>    <title>Music Survey</title>    <meta charset="utf-8"> </head> <style>    legend { font-weight:bold;    }    </style> <body> <h1>Music Survey</h1> <form method="post" action=""> <label for="myname"><b>Name:</b></label>        <input type="text" name="myname" id="myname">        <br><br> <label for="myemail"><b>Email:</b></label>        <input type="email" name="myemail" id="myemail">        <br><br>   <fieldset> <legend>Select Your Favorite Types of Music:</legend> <input type="checkbox"...
Can someone check to see if anything needs to be changed from this code? The instructions...
Can someone check to see if anything needs to be changed from this code? The instructions are confusing and I'm not sure if this fulfills everything because my compiler won't run it properly. DIRECTIONS: In this project we will develop classes to implement a Day Planner program. Be sure to develop the code in a step by step manner, finish phase 1 before moving on to phase 2. Phase 1 The class Appointment is essentially a record; an object built...
Can someone please convert this java code to C code? import java.util.LinkedList; import java.util.List; public class...
Can someone please convert this java code to C code? import java.util.LinkedList; import java.util.List; public class Phase1 { /* Translates the MAL instruction to 1-3 TAL instructions * and returns the TAL instructions in a list * * mals: input program as a list of Instruction objects * * returns a list of TAL instructions (should be same size or longer than input list) */ public static List<Instruction> temp = new LinkedList<>(); public static List<Instruction> mal_to_tal(List<Instruction> mals) { for (int...
please write the java code so it can run on jGRASP Thanks! CODE 1 1 /**...
please write the java code so it can run on jGRASP Thanks! CODE 1 1 /** 2 * SameArray2.java 3 * @author Sherri Vaseashta4 * @version1 5 * @see 6 */ 7 import java.util.Scanner;8 public class SameArray29{ 10 public static void main(String[] args) 11 { 12 int[] array1 = {2, 4, 6, 8, 10}; 13 int[] array2 = new int[5]; //initializing array2 14 15 //copies the content of array1 and array2 16 for (int arrayCounter = 0; arrayCounter < 5;...
Create CSS styling for this xml code 5.2. Change the CSS so only a single course...
Create CSS styling for this xml code 5.2. Change the CSS so only a single course is displayed. 5.2.1. You may add IDs or classes to the XML file a desired. <InformationSystems>    <Classes>        <CourseHeader>            <CourseNumber>CIS 145</CourseNumber>            <CourseName>Introduction to Relational Database</CourseName>            <Credits>5</Credits>        </CourseHeader>        <Description><![CDATA[Introduces relational database concepts and practices using business-related examples. OFTEC 111 or 108 recommended, or comparable competencies. Prerequisite: OFTEC 141 or MATH...
This is a code for a bouncing ball on an 8X8 LED. How can i change...
This is a code for a bouncing ball on an 8X8 LED. How can i change the code to make it a ping pong game against AI by adding 1 potentionmeter to control it? #include <TimerOne.h>//this is a library that uses timer 1 of the arduino to trigger interrupts in certain time intervals //This defines a matrix defining a smiley face for the 8x8 LED matrix display #define BALL { \ {1, 0, 0, 0, 0, 0, 0, 0}, \...
can someone code this problem please? Introduction Students will create a C++ program that simulates a...
can someone code this problem please? Introduction Students will create a C++ program that simulates a Pokemon battle mainly with the usage of a while loop, classes, structs, functions, pass by reference and arrays. Students will be expected to create the player’s pokemon and enemy pokemon using object-oriented programming (OOP). Scenario You’ve been assigned the role of creating a Pokemon fight simulator between a player’s Pikachu and the enemy CPU’s Mewtwo. You need to create a simple Pokemon battle simulation...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT