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;
cout<<"Enter name of the country : ";
getline(cin,country);
cout<<"\nWe hope you have a safe trip to the USA from
"<<country<<endl;
int flag=1;
while(flag){
cout<<"\nCoverter Toolkit"<<endl;
cout<<"----------------"<<endl;
cout<<"1. Temperature Coverter"<<endl;
cout<<"2. Distance Coverter"<<endl;
cout<<"3. Weight Coverter"<<endl;
cout<<"4. Quit"<<endl;
cout<<"Please select your option"<<endl;
int choice;
cin>>choice;
switch(choice){
case 1: float c;
cout<<"Enter temperature in celcius"<<endl;
cin>>c;
temperatureCoverter(c);
break;
case 2: float d;
cout<<"Enter distance in kilometers"<<endl;
cin>>d;
if(d>0)
distanceConverter(d);
else
cout<<"Invalid input!"<<endl;
break;
case 3: float w;
cout<<"Enter weight in kilograms"<<endl;
cin>>w;
if(w>0)
weightConverter(w);
else
cout<<"Invalid input!"<<endl;
break;
case 4: cout<<"Thank you for using this
program!"<<endl;
cout<<"<Your Name>"<<endl; // change
details
cout<<"<Project Number>"<<endl; // change
details
cout<<"<Due date>"<<endl; // change details
flag=0;
break;
default: cout<<"Invalid choice"<<endl;
break;
}
}
return 0;
}
// do comment if any problem arises
//code
#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;
cout << "Enter name of the country : ";
getline(cin, country);
cout << "\nWe hope you have a safe trip to the USA from " << country << endl;
int flag = 1;
while (flag)
{
cout << "\nCoverter Toolkit" << endl;
cout << "----------------" << endl;
cout << "1. Temperature Coverter" << endl;
cout << "2. Distance Coverter" << endl;
cout << "3. Weight Coverter" << endl;
cout << "4. Quit" << endl;
cout << "Please select your option" << endl;
int choice;
cin >> choice;
switch (choice)
{
case 1:
float c;
cout << "Enter temperature in celcius" << endl;
cin >> c;
temperatureCoverter(c);
break;
case 2:
float d;
cout << "Enter distance in kilometers" << endl;
cin >> d;
if (d > 0)
distanceConverter(d);
else
cout << "Invalid input!" << endl;
break;
case 3:
float w;
cout << "Enter weight in kilograms" << endl;
cin >> w;
if (w > 0)
weightConverter(w);
else
cout << "Invalid input!" << endl;
break;
case 4:
cout << "Thank you for using this program!" << endl;
cout << "<Your Name>" << endl; // change details
cout << "<Project Number>" << endl; // change details
cout << "<Due date>" << endl; // change details
flag = 0;
break;
default:
cout << "Invalid choice" << endl;
break;
}
}
return 0;
}
First test case:
Russia
1
20
4
Output:
Test case 2:
India
15
2
200
40
4
Output:
Test case 3:
China
3
80
1
27
0
4
Output:
C++ programming I need at least three test cases for the program and at least one...
c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...
c++ programming : everything is done, except when you enter ("a" ) in "F" option , it does not work. here is the program. #include <iostream> #include <string> #include <bits/stdc++.h> #include <iomanip> #include <fstream> using namespace std; #define MAX 1000 class Inventory { private: long itemId; string itemName; int numberOfItems; double buyingPrice; double sellingPrice; double storageFees; public: void setItemId(long id) { itemId = id; } long getItemId() { return itemId; } void setItemName(string name) { itemName = name; } string...
Redo Programming Exercise 7 of Chapter 7 so that your program handles exceptions such as division by zero and invalid input. Your program should print Denominator must be nonzero and reprompt for a valid denominator when 0 is entered for a denominator. Please specify what should go in the divisionByZero.h file and the changes made to main.cpp Please provide output. Thank you in advance! main.cpp so far #include <iostream> using namespace std; void addFractions(int num1, int num2, int den1, int...
THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #include "pch.h" #include #include using namespace std; // Function prototype void displayMessage(void); void totalFees(void); double calculateFees(int); double calculateFees(int bags) { return bags * 30.0; } void displayMessage(void) { cout << "This program calculates the total amount of checked bag fees." << endl; } void totalFees() { double bags = 0; cout << "Enter the amount of checked bags you have." << endl; cout <<...
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 am trying to run this program in Visual Studio 2017. I keep getting this build error: error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". 1>Done building project "ConsoleApplication2.vcxproj" -- FAILED. #include <iostream> #include<cstdlib> #include<fstream> #include<string> using namespace std; void showChoices() { cout << "\nMAIN MENU" << endl; cout << "1: Addition...
/*Colesha PearmanCIS247CATM ApplicationMay 4,2020*///Bring in our libaries#include"stdafx.h" #include<iostream>#include<conio.h>#include<string>#include<fstream>//read/write to files#include<ctime>//time(0)#include<iomanip>//setpresision stdusing namespace std; //create constant vaules-- cannot be changedconst int EXIT_VALUE = 5;const float DAILY_LIMIT = 400.0f;const string FILENAME = "Account.txt"; //create balance variabledouble balance = 0.0; //prototypesvoid deposit(double* ptrBalance);void withdrawal(double* ptrBalance, float dailyLimit); //overloaded method-this verision does not take withdrawal amount void withdrawal(double* ptrBalance, float dailyLimit, float amount); //overloaded method that takes withdrawal amount ///Enrty point to the application int main(){ //look for the starting balance; otherwise generate a random balance ifstream...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...
I'm just a beginner in programming,how to make this program more simple without using #include<iostream> and #include<redex> here is the question Terms to know: If-else statement,for..while..do while,loops,pointer,address,continue,return,break. Create a C++ program which contain a function to ask user to enter user ID and password. The passwordmust contain at least 6 alphanumeric characters, 1 of the symbols !.@,#,$,%,^,&,* and 1 capital letter.The maximum allowable password is 20. Save the information. Test the program by entering the User ID and password. The...
Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...