This is a fairly simple program and everything was fine until i was asked to declare the variable "relays" as an integer after doing so the code does not give me the proper output but if i declare the variable as double it works just fine. what am i missing?
Code:#include <iostream> //standard library for i/o#include <string> #include <iomanip> using namespace std; int main() { string user_response = "y"; string cell_num; double net_cost; double call_tax; double total_cost; double tax_rate; int relays = 0; int call_length; while (user_response == "y" || user_response == "Y") { //User Input cout << "Please input a cell phone number: "; cin >> cell_num; cout << "Please input the number of relay stations used: "; cin >> relays; cout << "\nPlease input the length in minutes of the call: "; cin >> call_length; //tax rate based on number of relays if ((relays >= 1) && (relays <= 5)) tax_rate = .01; else if ((relays >= 6) && (relays <= 11)) tax_rate = .03; else if ((relays >= 12) && (relays <= 20)) tax_rate = .05; else if ((relays > 21) && (relays <= 50)) tax_rate = .08; else if (relays > 50) tax_rate = .12; // callculations net_cost = ((relays / 50) * 0.40) * call_length; call_tax = net_cost * tax_rate; total_cost = net_cost + call_tax; //Output cout << "\nCell Phone: " << cell_num; cout << "\nNumber of Relay Stations: " << relays; cout << "\nMinutes Used: " << call_length; // display cost with a 2 decimal places precision cout << setprecision(2) << fixed << "\nNet Cost: " << net_cost; cout << setprecision(2) << fixed << "\nCall Tax: " << call_tax; cout << setprecision(2) << fixed << "\nTotal Cost of Call: " << total_cost; cout << "\n\nWould you like to do another calculation (Y or N): \n" << endl; cin >> user_response; } return 0; }