Advertisement
Catdisk

hoja2Pregunta6

Sep 13th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <iostream>
  4.  
  5. using namespace System;
  6. using namespace std;
  7.  
  8. void input(int *consumo, char *tipo)
  9. {
  10.     *consumo = 0;
  11.     while (*consumo < 100)
  12.     {
  13.         cout << "Ingrese la cantidad de KWH consumidos: ";
  14.         cin >> *consumo;
  15.         if (*consumo < 100)
  16.             cout << "Cantidad de consumo minima NO superada!! (100 KWH)" << endl;
  17.     }
  18.     cout << "Ingrese el tipo de consumidor, ";
  19.     Console::ForegroundColor = ConsoleColor::DarkYellow;
  20.     cout << "p";
  21.     Console::ForegroundColor = ConsoleColor::Gray;
  22.     cout << "articular o ";
  23.     Console::ForegroundColor = ConsoleColor::DarkYellow;
  24.     cout << "c";
  25.     Console::ForegroundColor = ConsoleColor::Gray;
  26.     cout << "omercial: ";
  27.     cin >> *tipo;
  28. }
  29.  
  30. void calc(int *con, char *tipo, float *total)
  31. {
  32.    
  33.  
  34.     switch (*tipo)
  35.     {
  36.     case 'p':
  37.     case 'P':
  38.        
  39.         *total = *con * 1.58;
  40.         break;
  41.     case 'c':
  42.     case 'C':
  43.         for (int i = 0; i <= 100 || i <= *con; i++)
  44.         {
  45.             *total += 0.35;
  46.         }
  47.         for (int i = 100; i <= 500 || i <= *con; i++)
  48.         {
  49.             *total += 1.05;
  50.         }
  51.         for (int i = 500; i == *con; i++)
  52.         {
  53.             *total += 1.36;
  54.         }
  55.    
  56.     default:
  57.         cout << "ERROR";
  58.         _getch();
  59.         exit(0);
  60.         break;
  61.     }
  62. }
  63.  
  64. int main()
  65. {
  66.     int *consumo;
  67.     char *tipo;
  68.     float *precio;
  69.     tipo = new char;
  70.     consumo = new int;
  71.     precio = new float;
  72.  
  73.     input(consumo, tipo);
  74.     calc(consumo, tipo, precio);
  75.  
  76.     delete precio, consumo, tipo;
  77.     _getch();
  78.     return 0 ;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement