Question

In: Computer Science

Write a C++ program: The local taqueria has decided they need to raise their prices. In...

Write a C++ program:

The local taqueria has decided they need to raise their prices. In order to soften the blow to their customers, they also want to rename all their burritos to make them sound more desirable.

Your program should create two arrays in main() - one string array with 3 burrito types and one float array with 3 associated prices, defined below:

  string names[] = {"Carnitas", "Pollo", "Veggie"};
  float prices[] = {6.95, 6.25, 5.95};

Now, main should declare a string pointer and a float pointer. Using the pointers and a for loop, add " Especial" to the end of each element in the names array, and add 2.00 to each element in the prices array. Do not use array notation, i.e. names[1], use only pointer notation, i.e. *names or *(names+1) etc. Finally, using your pointers and a for loop, print out the new menu.

Hint: it is straightforward to append to a string in C++. If you have the following string:

string type = "Carnitas";

You can add " Especial" to the end of it by doing this:

type = type + " Especial";

After this, variable type now holds value "Carnitas Especial".

Solutions

Expert Solution

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.

code.cpp

#include <iostream>
using namespace std;

int main(){
   string names[] = {"Carnitas", "Pollo", "Veggie"};
   float prices[] = {6.95, 6.25, 5.95};

   int itemNum=3;
   for(int i=0;i<itemNum;i++){
       *(names+i) = *(names+i) +" Especial";
       *(prices+i) = *(prices+i) +2.0;
   }
   cout<<"New Item -> New Price"<<endl;
   for(int i=0;i<itemNum;i++){
       cout<<*(names+i)<<" -> "<<*(prices+i)<<endl;
   }
   return 0;
}


Related Solutions

C++ Program: Write another program (in C++) that will allocate a local static array of integers...
C++ Program: Write another program (in C++) that will allocate a local static array of integers and then a dynamic array of integers. Are they stored next to each other? You can examine this by examining the memory addresses where they are located. As described in class, on some systems the size of a dynamic array is actually stored in the bytes previous to a dynamically allocated array. Through some experiments on your own, try to see if this is...
Since the start of the pandemic, many retailers have decided to raise their prices in the...
Since the start of the pandemic, many retailers have decided to raise their prices in the hopes of making more profit. Is there decision justified? If not, what are the consequences of their decision of increasing prices?
Write a C program for this:ABC company decides to raise the salaries of its employees according...
Write a C program for this:ABC company decides to raise the salaries of its employees according to the following table: employee_status         years_of_service                    percent_raise                                Full-time                   less than 5 years                        4.0                   Full-time                   5 years or more                           5.0                   Part-time                   less than 5 years                         2.5                   Part-time                   5 years or more                           3.0 If employee_status value is ‘F’, the employee is full-time; if it is ‘P’, he or she is a part-time employee. Write a...
I need specific codes for this C program assignment. Thank you! C program question: Write a...
I need specific codes for this C program assignment. Thank you! C program question: Write a small C program connect.c that: 1. Initializes an array id of N elements with the value of the index of the array. 2. Reads from the keyboard or the command line a set of two integer numbers (p and q) until it encounters EOF or CTL - D 3. Given the two numbers, your program should connect them by going through the array and...
Write a C or C++ program using the fork() system call function. You will need to...
Write a C or C++ program using the fork() system call function. You will need to create 3 processes – each process will perform a simple task. Firstly, create an integer "counter" initialized to a random value between 1 and 100. Print this number to the console. This can be done by: Including the stdio.h and stdlib.h libraries Using the rand() function to generate your randomly generated number The main thread consists of the parent process. Your job is to...
in c++ you need to write a program that maintains the gradebook for a specific course....
in c++ you need to write a program that maintains the gradebook for a specific course. For each student registered in this course, the program keeps track of the student’s name, identification number (id), four exam grades, and final grade. The program performs several functionalities such as: enrolling a student in the course, dropping a student from the course, uploading student’s exam grades, displaying the grades of a specific student, displaying the grades of all students in the course, and...
Coding in C++: For this verse, you need to write a program that asks the user...
Coding in C++: For this verse, you need to write a program that asks the user to input the inventory id number (integer) and the price (float) for 5 inventory items. Once the 5 inventory items are input from the user, output the results to the screen. Please ensure you use meaningful names for your variables. If your variables are not named meaningfully, points will be deducted.
Write the program in C++ The Rebel food truck has asked you to write a program...
Write the program in C++ The Rebel food truck has asked you to write a program for them to do both inventory and sales for their food wagon. Ben and Dave run the food truck and they already have full time day jobs so they could really use your help. The food truck sells: hamburger, hotdogs, chilli, fries and soda. The truck has spots for 200 hamburger patties, 200 hot dogs, 75 hamburger buns, 75 hot dog buns, 500 ounces...
A local instructor wants you to write a c++ program using arrays to calculate the average...
A local instructor wants you to write a c++ program using arrays to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60 or above...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute an approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT