Find Jobs
Hire Freelancers

C++ project

$250-750 USD

Cerrado
Publicado hace más de 11 años

$250-750 USD

Pagado a la entrega
Looking to get help on writing this C++ program as it describe. thank you Do the Math! 1. Write a C++ program, [login to view URL], that computes arithmetic expressions entered in postfix notation. We are most familiar with infix notation to specify a computation: 3 + 4 * (8 – 2) * 5 Parentheses are needed to change the precedence of operations. Parentheses are not need for postfix notation. The above expression could be written as follows: 3 4 8 2 - * 5 * + To compute an expression in postfix notation, we use a stack. Whenever a number is encountered, it is added to the top of the stack. Whenever an operator is encountered, the operator is applied to the top two elements on the stack and the result replaces those two elements on the stack. For example, when the subtraction is encountered above, we would have the following occur: Stack Before Subtraction Stack after Subtraction Note for subtraction the top value is subtracted from the second value. For division, the top value is the divisor. The final result of the expression will be the number remaining in the stack at the end. Your program will use an array of integers to represent the stack. The program will repeatedly ask the user for one of four character commands: a : adds a given number to the stack c : computes for a given operator p : prints the current stack (top to bottom) q : prints the current stack and ends the program Your program should detect and print error messages for the following conditions: ? Command is not one of 4 given above ? Operator is not one of +, -, * or / ? A computation is requested when there are less than two numbers on the stack You are required to write the following three functions to help complete the task. The variable calculator is the array holding the stack values and top is the index of the top element in the stack. // add_number prompts the user for an integer, reads it in and // adds it to the top of the stack void add_number (int calculator [100], int& top); // compute prompts the user for an arithmetic operator and reads // it in. If the operator is illegal or there are less than two // elements on the stack, it prints an error message. Otherwise, // it applies the operator to the top two elements of the stack, // prints the result in equation form and replaces the top two // elements in the stack with the result. void compute (int calculator [100], int& top); // print_stack prints a label and then prints the elements of // the stack, one per line from top to bottom. void print_stack (int calculator [100], int top); Here is a sample run of the program (user input in bold): Enter a (add number), c (compute), p (print) or q (quit): p The current stack is: Enter a (add number), c (compute), p (print) or q (quit): a Enter an integer to add to the stack: 36 Enter a (add number), c (compute), p (print) or q (quit): c There are not enough numbers to apply an operator! Enter a (add number), c (compute), p (print) or q (quit): a Enter an integer to add to the stack: 19 Enter a (add number), c (compute), p (print) or q (quit): a Enter an integer to add to the stack: 10 Enter a (add number), c (compute), p (print) or q (quit): b Illegal command, enter one of a, c, p or q! Enter a (add number), c (compute), p (print) or q (quit): p The current stack is: 10 19 36 Enter a (add number), c (compute), p (print) or q (quit): c Enter the operator: - 19 - 10 = 9 Enter a (add number), c (compute), p (print) or q (quit): p The current stack is: 9 36 Enter a (add number), c (compute), p (print) or q (quit): c Enter the operator: & Illegal operator, enter one of +, -, * or / Enter a (add number), c (compute), p (print) or q (quit): c Enter the operator: / 36 / 9 = 4 Enter a (add number), c (compute), p (print) or q (quit): q The current stack is: 4 Done computing!
ID del proyecto: 2471655

Información sobre el proyecto

10 propuestas
Proyecto remoto
Activo hace 12 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
10 freelancers están ofertando un promedio de $305 USD por este trabajo
Avatar del usuario
Expert C++ developer. Available to start immediately.
$300 USD en 1 día
4,7 (160 comentarios)
7,0
7,0
Avatar del usuario
Can do it just for fun. Extremely easy task. Regards
$250 USD en 1 día
5,0 (9 comentarios)
5,7
5,7
Avatar del usuario
Hi, kindly check your inbox for my inquiries. Thanks.
$250 USD en 1 día
4,9 (77 comentarios)
5,5
5,5
Avatar del usuario
Hello, I have done this kind of assignments.
$250 USD en 1 día
4,8 (42 comentarios)
5,1
5,1
Avatar del usuario
Hi, I am a graduate in CS and working as a C++ programmer for 3+ years. I have done lots of similar projects both in academic courses and in professional life. I assure you of clean, efficient and optimized code with proper documentation. waiting for reply, thanks
$250 USD en 1 día
4,1 (7 comentarios)
4,5
4,5
Avatar del usuario
**************************************** Please Check PMB for more details.Thanks. ****************************************
$250 USD en 2 días
4,7 (8 comentarios)
3,5
3,5
Avatar del usuario
I'm computer science student.I've written many programs like this.I can help you in this task.
$250 USD en 1 día
5,0 (1 comentario)
2,7
2,7
Avatar del usuario
I can help you. This task is fun...
$250 USD en 1 día
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
Custom software development (<b><i>Removed by Admin</i></b>)
$750 USD en 1 día
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
I can do this job with the require quality in less than a day. Please conctact me if you are interested and see PM. Regards
$250 USD en 1 día
0,0 (0 comentarios)
0,0
0,0

Sobre este cliente

Bandera de UNITED STATES
Buffalo, United States
5,0
1
Forma de pago verificada
Miembro desde sept 9, 2012

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos 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)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.