Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ I don't know if this is right and I can't figure out how to code getchoice function //================================= //unsortedlist.h #include using namespace std; #ifndef

image text in transcribed

image text in transcribed

image text in transcribed

c++ I don't know if this is right and I can't figure out how to code getchoice function //================================= //unsortedlist.h #include using namespace std; #ifndef UNSORTEDLIST_H #define UNSORTEDLIST_H const int SIZE = 10; class UnsortedList { private: int numbers[SIZE]; int length; public: UnsortedList(); UnsortedList(); void insertItem(int num); void deleteItem(int num); bool isFull()const; bool isEmpty()const; }; #endif //================================ // unsortedlist.cpp #include"unsortedList.h" UnsortedList::UnsortedList() { length = 0; } UnsortedList::UnsortedList() { } void UnsortedList::insertItem(int num) { numbers[length] = num; length++; } void UnsortedList::deleteItem(int num) { int location = 0; while (num != numbers[location] && location

system("pause"); return 0; } void showMenu() { cout char choice; cout > choice; if (choice == 'a') { cout > num; list.insertItem(num); } else { } }

HW 3aCreate an array based UnsortedList data structuro Write a program that Implements an UnsortedList ADT. - The list will hold up to 10 unsorted integer values. - When the list is initially created, it should be empty. Numbers can be inserted into the list (as long as the list is not full). Numbers can be deleted from the list (as long as the list is not empty). - The list will be an array-based list. Project: HW 3a 3 Files UnsortedList.h UnsortedLIst.cpp main.cpp Note: Most of the code for this project is in the lecture notes. 1.) UnsortedList.h -This file contains an UnsortedList class specification numbers An array that holds integer values. Maximum number of items in the list is 10. (MAX SIZE 10) length A variable to keep track of the length of the list. 6 Public methods: Include these 6 methods: o Default constructor Sets the list to an empty list. o Destructor o insertitem An item is inserted into the list An item (integer) is passed from main() to the function, and inserted at the . end of the list. o deleteltem - An item is deleted from the list. An item (integer) is passed from main() to the function. " Starting at the beginning of the list, the item passed from main) is compared deleted, and an output message should display: Item has been deleted message should display: each item in the list. If the value from main) is equal to a value in the list, then the list item is If there is not an item in the list equal to the value from main), then an output Item is not in list. o isFull This method checks to see if the list is full. The function returns true if the list is full, and false if the list is not full No parameters are passed from main0. . . This method must be called before the insertiten method is called The insertitem method is called only if the list is not full. o IsEmpty This method checks to see lf the list is empty .The function returns true if the list is empty, and false if the list is not empty - No parameters are passed from main0 - This method must be called before the deleteltem method is called. The deleteltem method is called only if the list is not empty. 2) UnsortedList cpp - This fle contains the implementations of 3.) main.cpp-This file contains maino) contains the implementations of the six class methods. Declare an unsorted list object in main0. Ex UnsortedList list o In main0, call a showMenu function that displays a menu like this: a. Insert a number into the list. b. Delete a number from the list. In main0 call a getChoice function that displays this: o Enter your choice: a If the choice is a, then prompt user to enter a number Enter a number: 12 The list should be checked to determine if it is full. o If not full, then insert the number into the list. o If the choice is b, then prompt the user for the value to be deleted: o Enter the number to be deleted: 4 o The list should be checked to determine if it is empty If not empty, search the list for the number. . If the number is found, delete the number from the list, and display this message: Item has been deleted. If the number is not found, display this message: Item is not in the list. o Then call showMenu again, then getChoice again, and so on.... o Use a while loop to continually show the menu and get the user's choice - Make sure to insert more than 10 to test the isFull method. When the list is full, display this message The list is full cannot insert the number. Make sure to delete all of the numbers to test the isEmpty method. When the list is empty, display this message The list is empty

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

Students also viewed these Databases questions

Question

Acacia Mutual v. American General Life

Answered: 1 week ago

Question

2. What factors infl uence our perceptions?

Answered: 1 week ago

Question

Recognize the power of service guarantees.

Answered: 1 week ago

Question

Demonstrate how to use the Gaps Model for diagnosing and

Answered: 1 week ago