//1st program
#include <iostream>
using namespace std;
int main() {
float X,Y,Z;
cout << "Enter value of X:";
cin>>X; //user input for X
cout << "Enter value of Y:";
cin>>Y; //user input for Y
Z = 3*(X*X) - 4*(Y*Y); //computes Z
//print X,Y and Z
cout<<"X is:"<<X;
cout<<"\nY is: "<<Y;
cout<<"\nZ is: "<<Z;
//check if z is positive or negative
if(Z>=0)
{
cout<<"\n\nZ is positive";
}
else
{
cout<<"\n\nZ is negative";
}
return 0;
}
Output::
#include <iostream>
using namespace std;
int main() {
float R,S; //declared variable
cout<<"Enter the slimness ratio(R): ";
cin>>R; //user input for slimness ratio
//if R is less than zero then show message
if(R<0)
{
cout<<"R can't be negative";
}
else
{
//if R<120 compute S expression
if(R<120)
{
S = 17000-485*(R*R);
}
//if R>=120 compute S expression
else if(R>=120)
{
S = 18000/(1+((R*R)/18000));
}
//if R<0 then S is not available
else if(R<0)
{
S = -1; //-1 represents not available
}
//print the output
cout<<"For slimness ratio R = "<<R<<" the safe load is = "<<S;
}
}
Output::
Note:: If you have any queries please comment else Upvote please.
In C++ ab 8 DESCRIPTION: Complete all four problems. 1. Write a program that will accept...
Write a C++ Program Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: 1 Name: Your Name ID: Your ID #include <iostream> using namespace std; din main YOUR CODE HERE
In this exercise, write a complete Java program that reads integer numbers from the user until a negative value is entered. It should then output the average of the numbers, not including the negative number. If no non-negative values are entered, the program should issue an error message. You are required to use a do-while loop to solve this problem. Solutions that do not use a do-while loop will be given a zero. Make sure to add appropriate comments to...
1. (sumFrom1.cpp) Write a program that will ask the user for a positive integer value. The program should use the for loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, ... 50. If the user enters a zero or negative number, a message should be given and the program should not continue (see Sample Run...
Please help me program this in C! Description Given the following equations sets to calculate the value of variables x, y and z, a2+b Write a program that takes values for integers a and b as input and displays the values of the unknown variable triple (x, y and z) generated by the formulas above. Hint: The input variables a and b should be integers. In case you need to find a function from the math.h library, visit cplusplus.com Sample...
Write code that prompts the user to input a number. The program should then output the number and a message saying whether the number i "Positive, "Negative" or "Zero". It should further output whether the number is odd or even (zero is counted as even) For example:
Topics c ++ Loops While Statement Description Write a program that will display a desired message the desired number of times. The program will ask the user to supply the message to be displayed. It will also ask the user to supply the number of times the message is to be displayed. It will then display that message the required number of times. Requirements Do this assignment using a While statement. Testing For submitting, use the data in the...
Student ID: 123 Write a C+ program with the following specifications: a. Define a C++ function (name it function_StudentlD where StudentID is your actual student ID number) that has one integer input (N) and one double input (x) and returns a double output S, where N S = n 0 and X2 is given by 0 xeVn n 0,1 Хл —{2. nx 2 n 2 2 m2 x2 3 (Note: in the actual quiz, do not expect a always, practice...
Write a program that prompts the user for their quarterly water bill for the last four quarters. The program should find and output their average monthly water bill. If the average bill exceeds $75, the output should include a message indicating that too much water is being used. If the average bill is at least $25 but no more than $75, the output should indicate that a typical amount of water is being used. Finally, if the average bill is...
In C++ Programming Write a program in a file named SeedFinder.cpp that finds and displays all the seeds of a integer given by the user. Let’s define a seed of an integer, n, to be a positive value that equals n when multiplied by its individual digits. For example, 23 is a seed of 138 because 23 × 2 × 3 = 138. 111 is an example of a seed of itself because 111 × 1 × 1 × 1...
In C language using printf and scanf statements: Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representation of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...". The program will ask the user to enter a non-zero...