I really need help on this programming problem that am doing in Visual Studio 2019 in C++
Submit your .cpp file as well as the input file, the output file, and the screen shot of all the files tiled next to each other here!
Instructions:
Write a menu driven program that has three options:
Option 1: Write a function that calculates the tax for an iphone. The price and the tax rate should be asked from the user. Input validation: Do not accept negative numbers or string.
Option 2:
1- Create an input file with several numbers.
2- Read the numbers from your file into the program utilizing a for loop.
3- Multiply the numbers utilizing a for loop.
4- Write the result into a file.
Option 3: Exit the program
At the end of the program ask the user if they want to repeat the program or not, utilizing a do-while loop. ( If the user says yes to repeat, your program should start over again automatically)
What to submit: Submit the input file you have created, the output file that was created by your program, your .cpp file and the screen shot of the output( be sure all the files are tiled next to each other before taking the screen shot).
Let me know if you have any questions!
Hi,
Please refer screenshots for more clarity.
iphoneTax(): Asks user for price and tax in %, percentage % converted to normal decimal value. And adds price and tax.
Product(): For finding the product of all numbers in file, and writes result into different file.
C++ code:
//Program starts here.
#include <iostream>
#include <string>
#include <fstream>
#include<stdio.h>
#include <stdlib.h>
using namespace std;
void iphoneTax(){
float p;
cout << "Enter iphone price:";
cin >> p;
if(p < 0){//checking negative values
cout << "neg values... Try again.." << endl;
return;
}
float t;
cout <<"Enter Tax to be paid in % ";
cin >> t;
if(t < 0){
cout << "neg values... Try again.." << endl;
return;
}
float t_val = t/100;//converted to value from
%;
t_val = p*t_val;//Tax for iphone price
float total_cost = p + t_val;//iphone price + taxes
cout << "Total price including taxes: " << total_cost
<< endl;
}
void Product(){
cout << "Ente file name: ";
string s;
cin >> s;
ifstream file(s);//Input stream reading
string line;
long long int res = 1;
while(getline(file,line))
{//while end of the file
res = res * stoi(line);
}
cout << res << endl;
file.close();
cout << "Enter file name to write the result : ";
cin >> s;
ofstream myfile;//writing to the file
myfile.open(s);
myfile << "Product :";//writing text into the
file
myfile << res << endl;//writing result
here
myfile.close();
}
int main()
{
while(1){
cout << "1.iPhone Taxes \n2. Product of numbers from given
file \n3.Exit"<< endl;
cout <<"Enter your choice:";
int ch;
cin >> ch;
switch(ch)
{
case 1: iphoneTax();
break;
case 2: Product();
break;
case 3: return 0;
default : cout << "Enter valid option" << endl;
break;
}
}
}
//End of the program

Input file: (For product)



I really need help on this programming problem that am doing in Visual Studio 2019 in...
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;...
Please write this in C.
Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...
As we continue with our study of programming fundamentals, here is a short extra credit programming challenge involving selection control structures. To be specific, the program specifications below and the algorithm you develop and write will involve the set-up and use of either nested if-else statements and/or switch statements. Choose one of the following programming challenges below for this algorithm workbench extra credit programming challenge… ------------------------------------------------------------------------------------------- Finding median Use selection control structures to write a C++ program that determines the...
Description -- Microsoft Studio, Visual Basic Problem 6.1 Words Reversed - Write a program that uses a Do Loop so that the user may enter words using a popup Input Box. Once the user enters "STOP" , the program then displays all the words in a single string. The difficulty is that the words are displayed in reverse order with spaces. The program is initiated with a button. For example: The following words are entered separately one at a time:...
THIS MUST BE DONE ON VISUAL STUDIO Write a C# program that computes a the cost of donuts at your local Rich Horton’s store. The cost, of course, depends on the number of donuts you purchase. The following table gives the break down: Donuts Purchased Cost per Donut ($) = 15 0.75 A customer can save on the HST (13%) if they buy 12 or more donuts so only charge HST (use a constant) on the purchase if the customer...
I need help building a program on microsoft visual studio using c++ language. implement a program called "charword_freq.cpp" to determine the number of words and the number of occurrences of each letter in a block of text stored in a data file called “mytext.dat”. Define a word to be any string of letters that is delimited at each end by either whitespace, a period, a comma, or the beginning or end of a line. You can assume that the input...
Use C++ and Visual Studio
Word Finder Version Your version of word finder should allow players to find as many words as they can from the list of letters. Name the cpp file called wordFinder LastNameFirstName.cpp. Words must contain at least 3 letters but no more than 6 letters The program must first read the words from a file but only can read in at most 5 words from a text file. The program should skip words that contains less...
I am in C++ programming, I need help with this assignments. The answer in this assignments when I look for it it doesn't work in my visual studios. Can you please help me? I hardly have C in the class, if I fail I will fail the whole class and repeat this class again. The file named Random.txt contains a long list of random numbers. Download the file to your system, then write a program that opens the file, reads...
Need help with java programming. Here is what I need to do: Write a Java program that could help test programs that use text files. Your program will copy an input file to standard output, but whenever it sees a “$integer”, will replace that variable by a corresponding value in a 2ndfile, which will be called the “variable value file”. The requirements for the assignment: 1. The input and variable value file are both text files that will be specified in...
C++ and Using Microsoft Visual Studio. Write 2 programs: One program will use a structure to store the following data on a company division: Division Name (East, West, North, and South) Quarter (1, 2, 3, or 4) Quarterly Sales The user should be asked for the four quarters' sales figures for the East, West, North, and South divisions. The data for each quarter for each division should be written to a file. The second program will read the data written...