Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have created this c++ console program in visual studio 2015, it is working completely. I am trying to get Add New Job to save

I have created this c++ console program in visual studio 2015, it is working completely. I am trying to get "Add New Job" to save as a text file after the user enters the required values, then to be opened as a text file to be read if the user picks "Open Saved Job"

// ConsoleApplication22.cpp : Defines the entry point for the console application. //

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[]) { return 0; } #include

using namespace std;

int main() { int choice; bool gameOn = true; while (gameOn != false) { cout << "******************************* "; cout << " 1 - Start Ohmm's Law Calculator. "; cout << " 2 - Add New Job. "; cout << " 3 - Open Saved Job. "; cout << " 4- Check cost of wire per foot. "; cout << " 5 - Exit. "; cout << " Choose a program and press enter: ";

cin >> choice;

switch (choice) { case 1: cout << "Ohm's Law Calculator"; // Code for ohm's law calculator #include using namespace std;

{

int voltage, current, resistance, V, R, I, choose;

cout << " \t Ohm's Law Calculator"; cout << " Please Choose what you want to find out?"; cout << " 1. for voltage 2. for current 3. for Resistance" << endl; cin >> choice;

switch (choice) { case 1: cout << "Please Enter Value of Current in amps: "; cin >> I; cout << "Please Enter Value of Resistance in ohms: "; cin >> R; V = I*R; cout << "Voltage is: " << V << " volts" << endl; system("pause"); break;

case 2: cout << "Please Enter Value of Voltage in volts: "; cin >> V; cout << "Please Enter Value of Resistance in ohms: "; cin >> R; I = V / R; cout << "Current is: " << I << "amps" << endl; system("pause"); break;

case 3: cout << "Please Enter Value of Current in amps: "; cin >> I; cout << "Please Enter Value of voltage in volts: "; cin >> V; R = V / I; cout << "Resistance is: " << R << " ohms" << endl; system("pause"); break;

system("pause"); return 0; }

} break; case 2: cout << "Add New Job. "; // code for adding new job #include

using namespace std;

{

double wireType, wireLength, cost, totalCost, costLabor, jobCost;

cout << "Please enter the wire length in feet: "; cin >> wireLength;

cout << "Please enter the cost per foot in dollars: "; cin >> cost;

totalCost = wireLength*cost;

cout << "The total cost of wire is: " << totalCost << " dollars ";

cout << "Enter the cost of labor in dollars: " << endl; cin >> costLabor; jobCost = totalCost + costLabor;

cout << "The total job cost is: " << jobCost << " dollars ";

system("pause");

}

break; case 3: cout << "Edit a Job"; // code to edit a previous job

break;

case 4: cout << "Wire Cost"; #include

{ double wireSize, totalCost;

cout << " \t Please choose needed Wire Cost"; cout << " 1. cost for 6 gauge ALUMINUM wire 2. cost for 8 gauge ALUMINUM wire 3. cost for 10 gauge ALUMINUM wire 4. cost for 12 gauge ALUMINUM wire 5. cost for 6 gauge COPPER wire 6. cost for 8 gauge COPPER wire 7. cost for 10 gauge COPPER wire 8. cost for 12 gauge COPPER wire " << endl; cin >> choice;

switch (choice) { case 1: cout << "Cost per foot is: 0.59. Enter the length (in feet) of wire you need: "; cin >> wireSize; totalCost = wireSize* 0.59; cout << "The total cost of wire is :" << totalCost << " dollars" << endl; system("pause");

break;

case 2: cout << "Cost per foot is: 0.59. Enter the length (in feet) of wire you need: "; cin >> wireSize; totalCost = wireSize* 0.59; cout << "The total cost of wire is :" << totalCost << " dollars " << endl; system("pause"); break;

case 3: cout << "Cost per foot is: 0.49. Enter the length (in feet) of wire you need: "; cin >> wireSize; totalCost = wireSize* 0.49; cout << "The total cost of wire is :" << totalCost << " dollars " << endl; system("pause"); break;

case 4: cout << "Cost per foot is: 0.29. Enter the length (in feet) of wire you need: "; cin >> wireSize; totalCost = wireSize* 0.29; cout << "The total cost of wire is :" << totalCost << " dollars " << endl; system("pause"); break;

case 5: cout << "Cost per foot is: 0.89. Enter the length (in feet) of wire you need: "; cin >> wireSize; totalCost = wireSize* 0.89; cout << "The total cost of wire is :" << totalCost << " dollars " << endl; system("pause"); break;

case 6: cout << "Cost per foot is: 0.59. Enter the length (in feet) of wire you need: "; cin >> wireSize; totalCost = wireSize* 0.59; cout << "The total cost of wire is :" << totalCost << " dollars " << endl; system("pause"); break;

case 7: cout << "Cost per foot is: 0.39. Enter the length (in feet) of wire you need: "; cin >> wireSize; totalCost = wireSize* 0.39; cout << "The total cost of wire is :" << totalCost << " dollars " << endl; system("pause"); break;

case 8: cout << "Cost per foot is: 0.29. Enter the length (in feet) of wire you need: "; cin >> wireSize; totalCost = wireSize* 0.29; cout << "The total cost of wire is :" << totalCost << " dollars " << endl; system("pause"); break;

system("pause"); return 0; } break; }

case 5:

cout << "End of Program. "; gameOn = false; break; default: cout << "Not a Valid Choice. "; cout << "Choose again. "; cin >> choice; break; }

} return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions

Question

Understanding Conflict Conflict Triggers

Answered: 1 week ago

Question

=+C&B (especially taxation) laws, regulations, and practices?

Answered: 1 week ago

Question

=+designing international assignment C&B packages.

Answered: 1 week ago