0
This program is just to study nothing too serious.
I tried to use two means to do the screen cleaning, but from case 4 to work if I put the system ("cls")
or the function void clean()
, when removed system ("cls")
or the function void clean()
which is a routine to clean the screen, the program works normally.
Forgive me the presentation of the code here on the site, I still know very well to move here on the site.
//DesafioPrincipal.cpp
#include <iostream>
#include <cmath>
#include <cctype>
#include <iomanip>
#include <windows.h>
#include <clocale>
#include <stdlib.h>
using namespace std;
void EntradaDeDadoFuncionario1(float &func1c)
{
float func1;
char RESP;
do //FUNÇÃO PARA ENTRAR AS VENDAS DO FUNCIONARIO 1
{
cout <<"Entre o valor total de venda do Funcionario 1"<< endl;
cin >> func1;
func1c = func1c + func1;
cout << "Deseja inserir novas Vendas para este funcionario?" << endl;
cin >> RESP;
cin.ignore(80 ,'\n');
}
while (RESP == 'S' or RESP == 's');
}
void EntradaDeDadoFuncionario2(float &func2c)
{
float func2;
char RESP;
do
{
cout << "Entre o valor total de vendas do funcionario 2" << endl;
cin >> func2;
func2c += func2;
cout << "Deseja Inserir novas vendas para este funcionario?" << endl;
cin >> RESP;
cin.ignore(80, '\n');
}
while (RESP == 'S' or RESP == 's');
}
void EntradaDeDadoFuncionario3(float &func3c)
{
float func3;
char RESP;
do
{
cout << "Entre o valor total de vendas do funcionario 3" << endl;
cin >> func3;
func3c += func3;
cout << "Deseja Inserir novas vendas para este funcionario?" << endl;
cin >> RESP;
cin.ignore(80, '\n');
}
while (RESP == 'S' or RESP == 's');
}
void totalVendas(float Func1C, float Func2C, float Func3C)
{
float TotalDeVendas = Func1C + Func2C + Func3C;
cout << "Teste da Funcao: " << TotalDeVendas << endl;
}
void clear (void) //Rotina para limpar a tela
{
HANDLE TELA;
DWORD ESCRITA = 0;
COORD POS;
TELA = GetStdHandle(STD_OUTPUT_HANDLE);
POS.X= 0;
POS.Y= 0;
FillConsoleOutputCharacter(TELA, 32, 80 * 25, POS, &ESCRITA);
SetConsoleCursorPosition(TELA, POS);
}
void TestaValores(float func1C, float func2C, float func3C){
cout << "O total de venda do funcionario 1 e .......: "<< func1C << endl;
cout << "O total de venda do funcionario 2 e .......: "<< func2C << endl;
cout << "O total de venda do funcionario 3 e .......:"<< func3C << endl;
cout << "Resultado da soma na Main ..:"<< (func1C + func2C + func3C) << endl;
}
int main(void){
setlocale (LC_ALL,"");
float func1C = 0, func2C = 0, func3C = 0;
int OPCAO = 0;
cout << setprecision (2);
cout << setiosflags(ios::right);
cout << setiosflags(ios::fixed);
cout << "\n";
while(OPCAO != 5)
{
cout << "--------------------" << endl;
cout << "-Controle de Vendas-" << endl;
cout << "---Menu Principal----" << endl;
cout << "--------------------" << endl;
cout << "\n";
cout << "[1] --Funcionario 1--" << endl;
cout << "[2] --Funcionario 2--" << endl;
cout << "[3] --Funcionario 3--" << endl;
cout << "[4] -Total De Vendas-" << endl;
cout << "[5] -Fim do Programa-" << endl;
cout << "\n";
cout << "Escolha uma opcao:";
cin>> OPCAO;
cin.ignore(80 , '\n');
switch (OPCAO)
{
case 1:
EntradaDeDadoFuncionario1(func1C);
break;
case 2:
EntradaDeDadoFuncionario2(func2C);
break;
case 3:
EntradaDeDadoFuncionario3(func3C);
break;
case 4:
totalVendas(func1C, func2C, func3C);
break;
defaul:
cout << "Entre com uma opção válida!" << endl;
break;
}
}
TestaValores(func1C,func2C,func3C);
return 0;
}
But what error does it make? What does the program do that it shouldn’t do? What do you mean by "stops working" ? What exact line did you put the
system(cls)
? By the way, there’s a writing typodefaul
when it should bedefault
.– Isac
Another thing: note that in your functions you pass as parameter the address of a variable but do not use the content of that address to accumulate but rather the address itself. If you pass a variable as parameter not set such a variable in the body of the function.
– anonimo
From the Case 4 of the main function it simply does not perform the function that was put in the case 4, it even appears the function on the screen but soon disappears.
– Gustavo Daniel
The system I put at the beginning or end of the while, but in both ways gives the same error, the case 4 simply does not perform with should, present the total sales.
– Gustavo Daniel
I’m sorry, I don’t understand what you mean about the reference, could you explain to me???
– Gustavo Daniel