Question

Week 5: Add arrays to your program to handle more data. Examples: In the programming tutorial, add a tutorial on working with

includekiostream using na space std; int main() int flag 1; cout << Enter the material of ire: cin > nt; cout << Enter leng

Can someone please read the above directions and then add to the code I provided! its c++ thank you!

Week 5: Add arrays to your program to handle more data. Examples: In the programming tutorial, add a tutorial on working with arrays. Then use arrays to store the answers to multiple questions so that you can compute a total score. In the DJ program, you can add the ability to handle multiple songs and playlists. The electrical program should handle multiple customer scenarios.
includekiostream using na space std; int main() int flag 1; cout
Comments
    0 0
    Add a comment Improve this question Transcribed image text
    Answer #1

    #include <iostream>

    using namespace std;

    int main()

    {

    int flag=1;

    int n,k;

    k=0;

    cout<<"Enter the number of item"<<endl;

    cin>>n;

    int mt[n],lt[n],cs[n],lc[n],tc[n];

    do

    {

    cout<<"Enter the material of wire:";

    cin>>mt[k];

    do

    {

    cout<<"Enter length of wire:";

    cin>>lt[k];

    if(lt[k]<0)

    cout<<"Invalid choice"<<endl;

    }while(lt[k]<0);

    do

    {

    cout<<"Enter cost per feet:";

    cin>>cs[k];

    if(cs[k]<0)

    cout<<"Invalid choice"<<endl;

    }while(cs[k]<0);

    do

    {

    cout<<"Enter labor cost:";

    cin>>lc[k];

    if(lc[k]<0)

    cout<<"Invalid choice"<<endl;

    }while(lc[k]<0);

    tc[k]=lt[k]*12*cs[k];

    cout<<"The details are"<<endl;

    cout<<"Length of wire "<<lt[k]<<endl;

    cout<<"Cost per feet "<<cs[k]<<endl;

    cout<<"Labor cost "<<lc[k]<<endl;

    cout<<"Total cost of wire "<<tc[k]<<endl;

    cout<<"Press 1 to try again, press 0 to exit the program";

    cout<<"Enter your choice";

    cin>>flag;

    cout<<endl;

    k=k+1;

    }while(flag!=0);

    return 0;

    }

    OUTPUT

    Add a comment
    Know the answer?
    Add Answer to:
    Can someone please read the above directions and then add to the code I provided! its c++ thank you!
    Your Answer:

    Post as a guest

    Your Name:

    What's your source?

    Earn Coins

    Coins can be redeemed for fabulous gifts.

    Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
    Similar Homework Help Questions
    • In c++ Please. Now take your Project 4 and modify it.  You’re going to add another class...

      In c++ Please. Now take your Project 4 and modify it.  You’re going to add another class for getting the users name. Inherit it. Be sure to have a print function in the base class that you can use and redefine in the derived class. You’re going to also split the project into three files.  One (.h) file for the class definitions, both of them.  The class implementation file which has the member function definitions. And the main project file where your main...

    • I need a detailed pseudocode for this code in C ++. Thank you #include <iostream> #include...

      I need a detailed pseudocode for this code in C ++. Thank you #include <iostream> #include <string> #include <iomanip> using namespace std; struct Drink {    string name;    double cost;    int noOfDrinks; }; void displayMenu(Drink drinks[], int n); int main() {    const int size = 5;       Drink drinks[size] = { {"Cola", 0.65, 2},    {"Root Beer", 0.70, 1},    {"Grape Soda", 0.75, 5},    {"Lemon-Lime", 0.85, 20},    {"Water", 0.90, 20} };    cout <<...

    • C++ language I am having some trouble with user validation, can someone look at my code...

      C++ language I am having some trouble with user validation, can someone look at my code and tell me what I am doing wrong: char firstInital, lastInitial;    int userAge;    std::cout << "Program 1-2: Get user initials and age in days\n ";    std::cout << "-------------------------------------------------------------------------\n";    std::cout << "Please enter the first letter of your first name: \n " << flush;    std::cin >> firstInital;    std::cout << "Please enter the first letter of your last name: \n...

    • IN C++ Help to fix code Library management program. Error is when i type a letter...

      IN C++ Help to fix code Library management program. Error is when i type a letter into options menu the code breaks. after your edits, the code should still run as normal. CODE: #include<iostream> using namespace std; //structure to store library data class BookDetails{ public: struct library { int code; char title[20]; int status; }; library book_details[100]; }; //structure to store user data class UserDetails:public BookDetails{ public: struct users { int id; char name[20]; int booksNumber; }; users user_details[100]; };...

    • Code is in C++: Im wondering how i can make the program continue to ask the...

      Code is in C++: Im wondering how i can make the program continue to ask the user to enter Y/N with the if statment. Is it possible with an If statment? #include <iostream> using namespace std; int main() { float usDollars,cYuan; float *Dollars; char choice; Dollars = &usDollars; while(usDollars >= 0){ cout <<"Enter the amount in U.S Dollars: "; cin >> usDollars; cout << usDollars<< " U.S Dollar in Chinese Yuan is :"<<*Dollars*7.09<<endl; if (choice == 'y' || choice ==...

    • using the source code at the bottom of this page, use the following instructions to make...

      using the source code at the bottom of this page, use the following instructions to make the appropriate modifications to the source code. Serendipity Booksellers Software Development Project— Part 7: A Problem-Solving Exercise For this chapter’s assignment, you are to add a series of arrays to the program. For the time being, these arrays will be used to hold the data in the inventory database. The functions that allow the user to add, change, and delete books in the store’s...

    • IN C++ My project will be a library management system. It will have seven functions. It...

      IN C++ My project will be a library management system. It will have seven functions. It HAS to contain: classes, structures, pointers and inheritance. fix code according to below 1. Add a new book allows the user to enter in book name and book code Book code has to be in # “Invalid book code” “book name has been added to library” book code will be used to borrow books 2. Add a new user must use first user must...

    • -can you change the program that I attached to make 3 file songmain.cpp , song.cpp ,...

      -can you change the program that I attached to make 3 file songmain.cpp , song.cpp , and song.h -I attached my program and the example out put. -Must use Cstring not string -Use strcpy - use strcpy when you use Cstring: instead of this->name=name .... use strcpy ( this->name, name) - the readdata, printalltasks, printtasksindaterange, complitetasks, addtasks must be in the Taskmain.cpp - I also attached some requirements below as a picture #include <iostream> #include <iomanip> #include <cstring> #include <fstream>...

    • python programming: Can you please add comments to describe in detail what the following code does:...

      python programming: Can you please add comments to describe in detail what the following code does: import os,sys,time sl = [] try:    f = open("shopping2.txt","r")    for line in f:        sl.append(line.strip())    f.close() except:    pass def mainScreen():    os.system('cls') # for linux 'clear'    print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")    print(" SHOPPING LIST ")    print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")    print("\n\nYour list contains",len(sl),"items.\n")    print("Please choose from the following options:\n")    print("(a)dd to the list")    print("(d)elete from the list")    print("(v)iew the...

    • I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7:...

      I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account:      Customer name      Customer address      City      State      ZIP code      Telephone      Account balance      Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the...

    ADVERTISEMENT
    Free Homework Help App
    Download From Google Play
    Scan Your Homework
    to Get Instant Free Answers
    Need Online Homework Help?
    Ask a Question
    Get Answers For Free
    Most questions answered within 3 hours.
    ADVERTISEMENT
    ADVERTISEMENT
    ADVERTISEMENT