Find Jobs
Hire Freelancers

A Class with an Array: A stack

$30-75 USD

Concluído
Publicado há mais de 22 anos

$30-75 USD

Pago na entrega
Implement a LIFO, Last In First Out, data structure, also known as a "stack." Create a class Stack to implement a stack and use Push() and Pop() as its primary methods adding and removing items from it. Here is the prototype for the class Stack: #define SIZE 10 class Stack { private: double data[SIZE]; int top_of_stack; // keeps track of recent pushes public: void Init(); // or we could use a constructor void Push(double item_to_push); double Pop(); }; The client creates an empty stack of doubles with: Stack stk; [login to view URL](); Then, whenever the client wants to "push" something onto the stack, it calls [login to view URL]( some_number ); and when the client wants to remove an item and look at it, it calls: cout << [login to view URL](); If the client tries to Pop() from a stack with nothing on it, then an error should be generated. If it tries to Push() so that more than SIZE (or whatever the size of data is) items would end up on the stack, it also generates an error. Design a test main that creates at least two separate stack objects and pushes and pops items from each, printing as necessary. ## Deliverables Here is an example of an acceptable main(): int main() { Stack s1, s2; int k; // Initialize stacks ------------ [login to view URL](); [login to view URL](); // Test the Stack ----- cout << [login to view URL](); [login to view URL]( 2.34 ); [login to view URL]( 3.56 ); [login to view URL]( 7.89 ); // just for fun [login to view URL]( -1.003 ); [login to view URL]( 5000700 ); [login to view URL]( 123456789.123456789 ); [login to view URL]( 1 ); [login to view URL]( 2 ); [login to view URL]( 3 ); [login to view URL]( 4 ); [login to view URL]( 5 ); [login to view URL]( 6 ); cout << "\n------------ First Stack ------------\n"; for (k=0; k<8; k++) cout << [login to view URL]() << endl; cout << "\n------------ Second Stack ------------\n"; for (k=0; k<8; k++) cout << [login to view URL]() << endl; return 0; } and associated sample run: /* ------------------- SAMPLE RUN --------------- Stack Empty ------------ First Stack ------------ 5 3 1.23457e+08 5.0007e+06 7.89 3.56 2.34 Stack Empty ------------ Second Stack ------------ 6 4 2 1 -1.003 Stack Empty Stack Empty Stack Empty ---------------------------------------------- */ Use this to test that your class works, but submit a different main and run Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. Complete copyrights to all work purchased.
ID do Projeto: 2832221

Sobre o projeto

23 propostas
Projeto remoto
Ativo há 22 anos

Quer ganhar algum dinheiro?

Benefícios de ofertar no Freelancer

Defina seu orçamento e seu prazo
Seja pago pelo seu trabalho
Descreva sua proposta
É grátis para se inscrever e fazer ofertas em trabalhos
Concedido a:
Avatar do Usuário
See private message.
$21,25 USD em 14 dias
5,0 (80 avaliações)
5,2
5,2
23 freelancers estão ofertando em média $20 USD for esse trabalho
Avatar do Usuário
See private message.
$10,20 USD em 14 dias
5,0 (137 avaliações)
7,0
7,0
Avatar do Usuário
See private message.
$29,75 USD em 14 dias
4,4 (19 avaliações)
5,9
5,9
Avatar do Usuário
See private message.
$19,55 USD em 14 dias
5,0 (78 avaliações)
5,2
5,2
Avatar do Usuário
See private message.
$6,80 USD em 14 dias
5,0 (35 avaliações)
5,1
5,1
Avatar do Usuário
See private message.
$17 USD em 14 dias
4,9 (19 avaliações)
4,8
4,8
Avatar do Usuário
See private message.
$25,50 USD em 14 dias
4,6 (60 avaliações)
4,5
4,5
Avatar do Usuário
See private message.
$22,95 USD em 14 dias
4,5 (33 avaliações)
4,2
4,2
Avatar do Usuário
See private message.
$21,25 USD em 14 dias
5,0 (16 avaliações)
4,0
4,0
Avatar do Usuário
See private message.
$18,70 USD em 14 dias
5,0 (26 avaliações)
3,8
3,8
Avatar do Usuário
See private message.
$29,75 USD em 14 dias
4,9 (17 avaliações)
3,2
3,2
Avatar do Usuário
See private message.
$14,45 USD em 14 dias
4,7 (32 avaliações)
3,3
3,3
Avatar do Usuário
See private message.
$17 USD em 14 dias
4,8 (21 avaliações)
3,2
3,2
Avatar do Usuário
See private message.
$25,50 USD em 14 dias
5,0 (10 avaliações)
2,9
2,9
Avatar do Usuário
See private message.
$5,10 USD em 14 dias
5,0 (15 avaliações)
2,7
2,7
Avatar do Usuário
See private message.
$34 USD em 14 dias
5,0 (2 avaliações)
2,5
2,5
Avatar do Usuário
See private message.
$8,50 USD em 14 dias
4,2 (12 avaliações)
2,1
2,1
Avatar do Usuário
See private message.
$34 USD em 14 dias
5,0 (2 avaliações)
1,9
1,9
Avatar do Usuário
See private message.
$34 USD em 14 dias
5,0 (2 avaliações)
1,7
1,7
Avatar do Usuário
See private message.
$11,05 USD em 14 dias
5,0 (1 avaliação)
0,0
0,0
Avatar do Usuário
See private message.
$17 USD em 14 dias
0,5 (1 avaliação)
0,0
0,0

Sobre o cliente

Bandeira do(a) UNITED STATES
United States
5,0
79
Método de pagamento verificado
Membro desde out. 18, 2001

Verificação do Cliente

Obrigado! Te enviamos um link por e-mail para que você possa reivindicar seu crédito gratuito.
Algo deu errado ao enviar seu e-mail. Por favor, tente novamente.
Usuários Registrados Total de Trabalhos Publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Carregando pré-visualização
Permissão concedida para Geolocalização.
Sua sessão expirou e você foi desconectado. Por favor, faça login novamente.