I need help with this C++ problem
so far my algorithm is looking like this.
#include
using namespace std;
void input(char fullname[35], int weight, int distance);
double totalcharges();
main()
{
char fullname[35];
int weight;
int distance;
for(int i = 1; i <= 3; i++)
{
input(fullname, weight, distance);
}
}
void input(char fullname[35], int weight, int distance)
{
char f[35]; //full name
int w; // weight
int d; // distance
cout << "What is your full name? Please enter ` when done
typing name" << endl;
cin.getline(f, 35, '`');
cout << "What is the weight of the item?" <<
endl;
cin >> w;
while(w < 75)
{
cout << "sorry we dont ship anything under 75
lbs" << endl;
cout << "Come back again when you have denser
items." << endl;
cin >> w;
}
cout << "How far are your items going?" << endl;
cin >> d;
TotalCharges(f, w, d);
}
float TotalCharges(char name[35], int wt, int dt)
{
float laborcharge, travelcharge, totalcharge;
if(wt >= 100)
{
laborcharge = 4.00 * 100;
}
}
#include <iostream>
#include <iomanip>
using namespace std;
//Function declaration
void totalCharges(string name[],int weight[],int distance[]);
int main()
{
//Declaring arrays of size 3
string name[3];
int weight[3];
int distance[3];
/* This for loop will get the name ,weight
* of the furniture,distance enterd by the user
*/
for(int i=0;i<3;i++)
{
//Getting the Full name entered by
the user
cout<<"\nEnter Full name of
the customer "<<i+1<<":";
std::getline(std::cin,
name[i]);
while(true)
{
//Getting the weight of the
furniture entered by the user
cout<<"Enter Furniture Weight
(>=75 lbs) :";
cin>>weight[i];
/* Checking whether the weight is
less than 75 or not
* If yes,display error
message
*/
if(weight[i]<75)
{
//Displaying the
error message
cout<<"Invalid Value.Weight must be greater than or equal to
75"<<endl;
continue;
}
else
break;
}
//Getting the distance value
entered by the user
cout<<"Enter Distance to be
moved (Miles):";
cin>>distance[i];
cin.ignore();
}
//Calling the function which display the chart
totalCharges(name,weight,distance);
return 0;
}
/* Functin implementation which displays the labor charges,travel
charges and total charges
* Params : name ,wight,distance arrays
* Return : void
*/
void totalCharges(string name[],int weight[],int distance[])
{
//Declaring variables
double labourCharges=0.0;
double travelCharges=0.0;
double totalCharges=0.0;
//Setting the precision
std::cout << std::setprecision(2) <<
std::fixed;
//Dispalying the chart
cout<<"Name\t\tWeight\tDistance Labor
Charges\tTravel Charges\tTotal Charges"<<endl;
for(int i=0;i<3;i++)
{
//Calculating the labor
charges
labourCharges=(weight[i]/100)*4;
//calculating the Travel
charges
travelCharges=50+(distance[i]*1.75);
//Calculating the total
charges
totalCharges=labourCharges+travelCharges;
cout<<name[i]<<"\t"<<weight[i]<<"\t"<<distance[i]<<"\t\t"<<labourCharges<<"\t"<<travelCharges<<"\t\t"<<totalCharges<<endl;
}
}
___________________________
Output:
__________Thank You
I need help with this C++ problem so far my algorithm is looking like this. #include...
This is for a C++ program: I'm almost done with this program, I just need to implement a bool function that will ask the user if they want to repeat the read_course function. I can't seem to get it right, the instructions suggest a do.. while loop in the main function. here is my code #include <iostream> #include <cstring> #include <cctype> using namespace std; const int SIZE = 100; void read_name(char first[], char last[]); void read_course(int & crn, char des[],...
Help with C++ reverse program with leading zeros. I need to put the line from the function that display the zeros in main not in the function. So how can I move the display with leading zeros in main. Thanks. Here is my code. #include <iostream> #include <cstdlib> #include <iostream> using std::cout; using std::cin; using std::endl; //function templates int reverseNum(int); int main() { //variables char buf[100]; int num; while (true) { //prompt user for input cout << "Enter the number...
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;...
C++ getline errors I am getting getline is undefined error messages. I would like the variables to remain as strings. Below is my code. #include <iostream> #include<string.h> using namespace std; int index = 0; // variable to hold how many customers are entered struct Address //Structure for the address. { int street; int city; int state; int zipcode; }; // Customer structure struct Customer { string firstNm, lastNm; Address busAddr, homeAddr; }; // Functions int displayMenu(); Customer getCustomer(); void showCustomer(Customer);...
I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account: Customer name Customer address City State ZIP code Telephone Account balance Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the...
I need to be able to input first and last name. My code only outputs first when you put 2 names. This is not my full code. Any type of help wou;d be great! int main() { int main_choice; int grade_choice; int std_id; int new_grade; char g_name[100]; char s_name[100]; float a,b,c; gradebook g; do { cout <<endl; cout<< " -=| MAIN MENU |=-" << endl; cout<< "1. Add a student" << endl; cout << "2. Remove a student" << endl;...
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...
Need help with a C++ program. I have been getting the error "this function or variable may be unsafe" as well as one that says I must "return a value" any help we be greatly appreciated. I have been working on this project for about 2 hours. #include <iostream> #include <string> using namespace std; int average(int a[]) { // average function , declaring variable int i; char str[40]; float avg = 0; // iterating in...
C++ problem where should I do overflow part? in this code do not write a new code for me please /////////////////// // this program read two number from the user // and display the sum of the number #include <iostream> #include <string> using namespace std; const int MAX_DIGITS = 10; //10 digits void input_number(char num[MAX_DIGITS]); void output_number(char num[MAX_DIGITS]); void add(char num1[MAX_DIGITS], char num2[MAX_DIGITS], char result[MAX_DIGITS], int &base); int main() { // declare the array = {'0'} char num1[MAX_DIGITS] ={'0'}; char...
#include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int charcnt(string filename, char ch); int main() { string filename; char ch; int chant = 0; cout << "Enter the name of the input file: "; cin >> filename; cout << endl; cout << "Enter a character: "; cin.ignore(); // ignores newline left in stream after previous input statement cin.get(ch); cout << endl; chcnt = charcnt(filename, ch); cout << "# of " «< ch« "'S:...