// Program: name of program
// Author: your name
// Date Written: date you began writing the program
/* Abstract: Brief description of the program */
Include in-line comments in the body of your program.
You can convert temperature from degrees Celsius to degrees Fahrenheit by multiplying by 9/5 and adding 32. Write a C++ program that allows the user to enter a floating-point number representing degrees Celsius, and then displays the corresponding degrees Fahrenheit.
Algorithm (IPO chart, pseudocode or flowchart, desk check test data)
C++ program.
Screen shot of running program using test data from
---------------------------------------------------
No 2
At the top of every program program file you create, put the following as comments:
// Program: name of program
// Author: your name
// Date Written: date you began writing the program
/* Abstract: Brief description of the program */
Include in-line comments in the body of your program.
Write a working C++ program that calculates the values of the variables x, and y using the following formulas.
x = (b2- 4ac) / 2a
y = (-b + (b2- 4ac)) / 2a
For simplicity, assume a, b, and c are integers.
Prompt the user for initial values for a, b and c.
Accept values from user for a, b and c.
Choose appropriate data type for x and y.
Calculates the values for x and y based on user input for a, b and c and using the formulas provided.
Display the values of x and y to the user.
// Program: Calculating x and y
// Author: Your Name
// Date Written: Date
/* Abstract: This program calculates the values of x and y using the formulas x = (b2- 4ac) / 2a and y = (-b + (b2- 4ac)) / 2a */
#include <iostream>
using namespace std;
int main()
{
// Declare variables
int a, b, c;
double x, y;
// Prompt user for values of a, b and c
cout << "Please enter values for a, b and c: ";
cin >> a >> b >> c;
// Calculate values of x and y
x = (b*b - 4*a*c) / (2*a);
y = (-b + (b*b - 4*a*c)) / (2*a);
// Display values of x and y
cout << "The value of x is: " << x << endl;
cout << "The value of y is: " << y << endl;
return 0;
}
To write a C++ program that converts temperature from degrees Celsius to degrees Fahrenheit, you can follow these steps:
1. Start by including the necessary header file for input/output operations:
```cpp
#include <iostream>
```
2. Declare the main function, which is the entry point of your program:
```cpp
int main() {
// code goes here
return 0;
}
```
3. Inside the main function, declare a variable to store the temperature in degrees Celsius:
```cpp
double celsius;
```
4. Prompt the user to enter the temperature in degrees Celsius:
```cpp
std::cout << "Enter temperature in degrees Celsius: ";
```
5. Read the user's input and store it in the `celsius` variable:
```cpp
std::cin >> celsius;
```
6. Perform the conversion from Celsius to Fahrenheit using the formula mentioned in the problem:
```cpp
double fahrenheit = (celsius * 9 / 5) + 32;
```
7. Display the converted temperature in degrees Fahrenheit to the user:
```cpp
std::cout << "Temperature in degrees Fahrenheit: " << fahrenheit << std::endl;
```
Here's the complete program:
```cpp
#include <iostream>
int main() {
double celsius;
std::cout << "Enter temperature in degrees Celsius: ";
std::cin >> celsius;
double fahrenheit = (celsius * 9 / 5) + 32;
std::cout << "Temperature in degrees Fahrenheit: " << fahrenheit << std::endl;
return 0;
}
```
To run the program, you can compile and execute it using a C++ compiler.