Write a program that incorporates these functions and statements: • list • while loop • for loop • if • print() • input() • concatenation
This program must create a grocery shopping list based on the user input • the program will ask a user to enter a new grocery item until the user presses Enter • then all user input will be added to a list • then the list with all grocery items will be printed
Since, you haven't mentioned any preferred language, i assume language is not an issue and program is all that matters.
C++
#include <bits/stdc++.h>
using namespace std;
vector<string>grocery_list; ///list
vector<string> input(string str)
{
int n=str.length();
int startIndex=0;
vector<string>temp;
///////FOR LOOP///////////
for(int i=0;i<=n;i++)
{
//If statement
if((str[i]=='\0')||(str[i]==','))
{
temp.push_back(str.substr(startIndex,i-startIndex));
startIndex=i+1;
}
}
return temp;
}
void print()
{
int index=0;
cout<<endl<<endl;
cout<<"*****************LIST************************\n";
////WHILE LOOP////
while(index<grocery_list.size())
{
cout<<"\t\t"<<grocery_list[index]<<endl;
index++;
}
cout<<"*********************************************\n";
}
int main()
{
cout<<"Enter the grocery item: ";
string str; getline(cin,str);
grocery_list=input(str); ///input function
print(); ///print function
return 0;
}
OUTPUT:

I have tried my best to complete all the functionalities the way u asked for. If you feel difficulty in understanding any portion or any functionality, do let me know in the comment box.
Write a program that incorporates these functions and statements: • list • while loop • for...
Q1 (2 pts) Shopping list
Write a program that prompts a user for items on their shopping
list and keeps prompting the user until they enter "Done" (make
sure your program can stop even if the user enters "Done" with
different cases, like "done"), then prints out the items in the
list, line by line, and prints the total number of items on the
shopping list.
Output (after collecting items in the while loop) should look
something like this:
Apple...
Note: You must write this program in Python. General Requirements The program should display a menu and allow the user to perform one of the following tasks. Add an item to the list Delete an item from the list Print the list Print the list in reverse Quit the program The program should run until the user chooses to quit. In Python, programmatically quitting the application is achieved with the exit() procedure. You should use a List to store the...
OBJECTIVES: To understand repetition structures To use while loops in a program To understand break and/or continue instructions Write a Python program (with comments) to do the following: Create a variable count and initialize it to 0 Create a variable colors and initialize it to [] (i.e. an empty list) Ask the user if they would like to enter up to 3 favorite colors. They should enter ‘y’ or ‘n’. Assume they will enter a valid input. Save the response...
working on a Python program, making a shopping list giving the user
several options:to view the list, to add an item or to delete and
an option to exit the program. It's not working at all. please
help.
File Edit Format Run Options Window Help class shopping: det init (self, final list): self.final_list=1 det add_item(self, item): self.final list.append(item] print("The added temi " + str(item) + ".") det delete item(self, item): gelf.final list.remove(item) print (the deleted item is "+ste (item) +".")...
USE of C++ please
Write a program that achieves the following requirements: 1. A while/do-While loop that will ask the user to input an integer on each iteration. The loop keeps a running total of the input and exits only when the total exceeds the first input times 10. 2. A for loop that does the exact same thing. The program should print out the *new* total each time the total is input.
NOTE: USE PYTHON CS160 Computer Science Lab 14 Working with lists, functions, and files Objective: Work with lists Work with lists in functions Work with files Assignment: Part 1: Write a program to create a text file which contains a sequence of test scores. Ask for scores until the user enters an empty value. This will require you to have the scores until the user enters -1. After the scores have been entered, ask the user to enter a file...
Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (‘ ‘), then a newline character (‘\n’) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...
a) Write a program that uses a while loop to print all divisors of a number supplied by the user. The program should also print the sum of all the divisors and whether the number the user entered is a prime number or not. Note: The definition of a divisor is a number that divides another evenly (i.e., without a remainder) and the definition of a prime number is a number whose only divisors are 1 and itself. b) Implement...
write in python Create a program that will ask the user for a list of integers, all on one line separated by a slash. construct a list named "adj_numbers" which contains the users input numbers after subtracting 2 from each number. then print the resulting list. the input statement and print statement are given to you in the starting code. a sample run of the program is as follows: Enter a list of integers, separated by slashes: 7/3/6/8 resulting list:...
NOTE:- NO "BREAK" COMMAND PLEASE This program allows the user to create a grocery list, which will give them a breakdown of each item they want to buy, including the amount that should be purchased. The program must use two separate lists to accomplish this! The user can continue entering items indefinitely, stopping only when theyenter the sentinel value “END”. After entering each item, they should be asked how many of that item they want to buy. After their list...