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

(Write a program in C++) A local instructor wants you to write a program to calculate...
(Write a program in C++) A local instructor wants you to write a program 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...
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...
Write a C++ die roller program. We need you to write a program that will roll...
Write a C++ die roller program. We need you to write a program that will roll dice for them, but not just six-sided dice. Your program needs to be able to take an input in for form nDx or ndx where the d is the letter d or D. n may or not be present. If it is, it represents the number of dice. If not, assume it is a 1. x may or may not be present. If it...
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?
I need write a small "c" program that has locations of items on a shelving unit....
I need write a small "c" program that has locations of items on a shelving unit. Im not familiar with this language. Can you guys give me some hint so I could start writing one or as example. This is my first time learning programming C. Specifically, your program should: Contain a struct representing an item on the shelf. It needs only contain the item's name and price. Ask the user for the number of shelves in the unit, and...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT