I need help with this program. Im trying to use C++ programming language.
I want to include my ifstream SimpleCal6.txt and my outFile.
CS 317
Calculator Program
Write a program to input three values, two floats and an operator print out what were read and the resulting evaluation. The operators to handle are +, -, *, / and ^. The floats are one or more digits in length. The last input is sentinel value 0 + 0;
Read a float, char, float for input. cin >> v1 >> opchar >> v2;
Input File: SimpleCal6.txt
Example input:
78.2 + 9.0
Example Output:
78.2 + 9.0 = 87.2
...
These are the data for SimpleCal6.txt
78.2 + 99.0 84.3 – 5.2 605.24 * 34.72 999.3 / 333.9 1010.10 + 1010.10 -5.5 * -3.8 5.89 * .00 0.04 - 0.09 -32.6 ^ 8.0 5.0 ^ 6.0 7.8234 - 7.8234 0.12 ^ 0.045 567.89 - 345.23
Main.cpp
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
main()
{
float varOne;
float varTwo;
char operatorType;
float value = 0.0;
ifstream inputFile;
inputFile.open("SimpleCal6.txt");
while (inputFile >> varOne >> operatorType >>
varTwo) {
if(operatorType == '+')
{
value = varOne + varTwo;
}
else if(operatorType == '-')
{
value = varOne - varTwo;
}
else if(operatorType == '*')
{
value = varOne * varTwo;
}
else if(operatorType == '^')
{
value = pow(varOne, varTwo);
}
else if(operatorType == '/')
{
value = varOne / varTwo;
}
cout << varOne << " " << operatorType << "
" << varTwo << " = " << value <<
endl;
}
inputFile.close();
}
Input file
78.2 + 99.0
84.3 - 5.2
605.24 * 34.72
999.3 / 333.9
1010.10 + 1010.10
-5.5 * -3.8
5.89 * .00
0.04 - 0.09
-32.6 ^ 8.0
5.0 ^ 6.0
7.8234 - 7.8234
0.12 ^ 0.045
567.89 - 345.23
Output
78.2 + 99 = 177.2
84.3 - 5.2 = 79.1
605.24 * 34.72 = 21013.9
999.3 / 333.9 = 2.99281
1010.1 + 1010.1 = 2020.2
-5.5 * -3.8 = 20.9
5.89 * 0 = 0
0.04 - 0.09 = -0.05
-32.6 ^ 8 = 1.27568e+12
5 ^ 6 = 15625
7.8234 - 7.8234 = 0
0.12 ^ 0.045 = 0.908998
567.89 - 345.23 = 222.66
I need help with this program. Im trying to use C++ programming language. I want to...
I need help debugging this C++ prgram. What Am i doing wrong? //******************************************************** // This program reads two input files whose lines are //ordered by a key data field. This program should merge //these two files, writing an output file that contains //all lines from both files ordered by the same key field. // //********************************************************* #include <iostream> #include<string> #include<fstream> //prototype void mergeTwoFiles (ifstream&,ifstream&, ofstream&); using namespace std; int main() {string inFile1,inFile2,outFile; // input and output files ifstream in1; ifstream in2;...
Hey, so i am trying to have my program read a text file using a structure but i also want to be able to modify the results(I kinda have this part but it could be better). I cant seem to get it to read the file(all the values come up as 0 and i'm not sure why because in my other program where it wrote to the txt file the values are on the txt file) i copied and pasted...
C++ programming I need at least three test cases for the program and at least one test has to pass #include <iostream> #include <string> #include <cmath> #include <iomanip> using namespace std; void temperatureCoverter(float cel){ float f = ((cel*9.0)/5.0)+32; cout <<cel<<"C is equivalent to "<<round(f)<<"F"<<endl; } void distanceConverter(float km){ float miles = km * 0.6; cout<<km<<" km is equivalent to "<<fixed<<setprecision(2)<<miles<<" miles"<<endl; } void weightConverter(float kg){ float pounds=kg*2.2; cout<<kg<<" kg is equivalent to "<<fixed<<setprecision(1)<<pounds<<" pounds"<<endl; } int main() { string country;...
The following program is in c++ ; I am trying to read in games from a file and when doing so I am only reading in parts of the file. It is giving me a segmentation fault error I am going to post my code below if anyone is able to help me debug the program I would greatly appreciate it. The program is too large to be submitted as a single question on here :( --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void Business::addGamesFromFile() {...
I need help programming this question using C language. This program uses input data entered in command line at the same time when the command or .exe file is entered. They are called command-line arguments. Because everything entered in command line is taken as a string, these arguments including the command itself or the .exe file name are stored in an array of char pointers, each pointer points to the first character of a string (i.e., argument). The inputs can...
I really need help with this python programming assignment Program Requirements For part 2, i need the following functions • get floats(): It take a single integer argument and returns a list of floats. where it was something like this def get_floats(n): lst = [] for i in range(1,n+1): val = float(input('Enter float '+str(i)+': ')) lst.append(val) return lst • summer(): This non-void function takes a single list argument, and returns the sum of the list. However, it does not use...
I need help with using the infile and outfile operations in C++... Here's my assignment requirements: Assignment: Cindy uses the services of a brokerage firm to buy and sell stocks. The firm charges 1.5% service charges on the total amount for each transaction, buy or sell. When Cindy sells stocks, she would like to know if she gained or lost on a particular investment. Write a program that allows Cindy to read input from a file called Stock.txt: 1. The...
I need help with this program using c++ language! CS 317 Program Assignment Name Arrange You are to write a program that will read in each person’s name and print out the results. The list has been collected form different places and the names are not in some standard format. A person’s last name may appear last or it may appear first. A label has been associated with each name to identify where the last name appears. Either “surname” or...
I am trying to modify this program so that it stores the employee's name in a c-string and can handle up to 100 employees (so it would mostly be a partially filled array), but I cannot get it to work. It works with two files that it is suppose to read input from. Then it prints output to an output file. Employee Info File (first file read, M/F should be ignored): 5 Christine Kim 30.00 2 1 F 15 Ray...
Please I need help in C language, I am trying to modify the code per the below instructions, but I am getting errors. Can't fgure it out. The attempted code modification and data file is privided below, after the instructions. Thank you. Instructions: 1. First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts....