Write a program which declares a structure CASalesTax. Member variables should i
ID: 3657728 • Letter: W
Question
Write a program which declares a structure CASalesTax. Member variables should include city (string), taxRate (float), and county (string). Declare an array in main of 1720 CASalesTax elements. Locate a text file named city_rates.csv in your Course Materials area. Your program should initialize the array by reading the file into the array. The file is sorted into city order already. Prompt for a city name, perform a BINARY SEARCH on the array, and return the corresponding sales tax rate and county name. Hints: A .csv file uses commas to separate values of one record. It will open with Excel. Use getline(infile, city, ','); to read a city name which might contain spaces. The getline stops at the comma. Use getline(infile, stringbuffer, ','); to read in a numeric value. Then, num = strtoul(stringbuffer.c_str(), 0, 10); to convert stringbuffer to integer, or strtod(stringbuffer.c_str(), 0); to convert the stringbuffer to a long real. There is no error checking here! Use getline(infile, buffer, ' '); on the last value in the record, as it uses a newline instead of a comma.Explanation / Answer
////store-source.cpp calculates a//// /////sample store's item's price///// ///////sale, code number and tax///// ///////Created by Ted - 09/02/2011/// #include #include #include using std::cout; using std::cin; using std::endl; using std::string; using std::setprecision; using std::fixed; using std::getline; int main(){ /*Declare variables and constants*/ bool n = false; //n stands for Nike bool a = false; //A for Adidas bool o = false; //O for OP const double nike = 15.99; const double adidas = 14.98; const double op = 12.99; double shoe_size = 1.50; int choice = 0; char prompt_1 = ' '; int item_code = 0; string name = " "; double final_price = 0.00; double tax = 0.06; double priceToAdd = 0.00; /*get user input*/ coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.