// C++ program to calculate resistance with comments
#include<bits/stdc++.h>
using namespace std;
int main()
{
//character to see whether user want to enter another batch or not
char ch;
do
{
cout<<"Enter batch name\n";
string batch_name;
cin>>batch_name;
cout<<"Enter the number of resistors in the current batch\n";
// high resistors is the count of total number of resistors that were too high
// same for low resistors
int total_resistors=0,high_resistors=0,low_resistors=0;
double avg_resistance=0,sum_avg_resistors=0;
cin>>total_resistors;
// if total resistors is 0 or less then enter again
while(total_resistors<1)
{
cout<<"Please enter number of resistors(atleast one)\n";
cin>>total_resistors;
}
// for loop for entering resistance of all resistors of this batch
for(int i=0;i<total_resistors;i++)
{
double curr_resistance;
cout<<"Enter resistance for resistor "<<(i+1)<<endl;
cin>>curr_resistance;
// if resistance entered is negative or zero then enter again
while(curr_resistance<=0)
{
cout<<"Again enter correct resistance for resistor "<<(i+1)<<endl;
cin>>curr_resistance;
}
// if resistance is greater than 3.5 then increment count of total number of high resistors
if(curr_resistance>3.5)
high_resistors++;
// else if resistance is less than 3.0 then increment count of total number of low resistors
else if(curr_resistance<3.0)
low_resistors++;
// else increment sum of resistance of avg resistors
else
sum_avg_resistors+=curr_resistance;
}
// find total number of average resistors
int avg_resistors=total_resistors-high_resistors-low_resistors;
// calculate average resistance
avg_resistance=sum_avg_resistors/avg_resistors;
// print the information
cout<<"Batch name is "<<batch_name<<endl;
cout<<"Number of resitors in the batch are "<<total_resistors<<endl;
cout<<"Number of too high resitors in the batch are "<<high_resistors<<endl;
cout<<"Number of too low resitors in the batch are "<<low_resistors<<endl;
cout<<"Average resistance of this batch is "<<avg_resistance<<endl;
// prompt user for another batch
cout<<"Do you want to evaluate another batch(y for yes, n for no)?"<<endl;
cin>>ch;
// if ch=='y' then proceed again
}while(ch=='y');
return 0;
}
Problem: Create a program that will ask scientist in tracking the resistances of products from various...
In c# create a program that generates a random number from 1 to 1000. Then, ask the user to guess the random number. If the user's guess is too high, then the program should print "Too High, Try again". If the user's guess is too low, then the program should print "Too low, Try again". Use a loop to allow the user to keep entering guesses until they guess the random number correctly. Once they figure it, congratulate the user....
Guess the number! You will create a program that will ask the user to guess a number between 1 and 10. The pseudocode is below. Be sure to import random at the beginning of your code and use a comment block explaining what your program does #Guess the number week 4 #Name: #Date: #Random number, loop while true #ask user for number. #if number is too high or too low, tell user, if they guessed it break out of loop...
Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed; they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has entered all the scores they want, your program will calculate and print the average of those scores. After printing the average, the program should terminate. You need to use a while loop...
in Java, temperature problem Create a package named temperature and create a program that has a while loop. • • Inside the while loop, your program will prompt the user for temperature in Centigrade. If the Centigrade value read in is <= -100. the loop will exit. Otherwise, your program will compute the Fahrenheit equivalent temperature. Inside the while loop, your program will print out the Centigrade and Fahrenheit temperatures. Keep a count of the valid user inputs and a...
Java Project In Brief... For this Java project, you will create a Java program for a school. The purpose is to create a report containing one or more classrooms. For each classroom, the report will contain: I need a code that works, runs and the packages are working as well The room number of the classroom. The teacher and the subject assigned to the classroom. A list of students assigned to the classroom including their student id and final grade....
This program will ask the user to enter a number of players, then ask the user for each player's name and score. Once all of the players have been entered, the program will display a bar chart with each of their scores scaled as a percentage of the maximum score entered. See below for details on exactly how this should work - an example transcript of how the program should work is shown below (remember that values entered by the...
Ask uFor Ex. "Prompt user to enter a number" = user enters 10, your program should output 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.ser to input a number, and then using a loop control statement (While, For, Do-While), output to the console the numbers beginning from 1, up to and including the number input by the user.
need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that first prompts the user for an upper limit: Enter the number of entries: 5 € (user enters 5) After the user enters a number, the program should prompt the user to enter that many numbers. For example, if the user enters 5, then the program will ask the user to enter 5 values. Use a do-while loop to add the numbers. o With each...
Write a code for a ride tracking app for Large Resort parks. In your app users are going to be able to track wait times for up to five attractions, find the shortest wait time, and find the average wait time. //-----------------------------Sample Program Behavior with five attractions entered--------------------- Welcome to Large Resort Parks! Please enter the attractions you plan to visit and their wait times Ride 1 info: Attraction Name: 80 ft drop Wait time (in minutes): 40 Enter another...
(c++) Write a program that generates a random number between 1 and 100 and asks the user to guess what the number is. If the user’s guess is higher than the random number, the program should display “Too high, try again.” If the user’s guess is lower than the random number, the program should display “Too low, try again.” The program should use a loop that repeats until the user correctly guesses the random number. Be sure that your program...