Advertisement
khisby

[SOAL11]boiling_point_of_several_substances

Oct 9th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. // Khisby Al Ghofari, 06.2017.1.06852, Kelas B
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int value,water,mercury,copper,silver,gold,water_p,mercury_p,copper_p,silver_p,gold_p;
  9.     string substance;
  10.     cout << "\n==============================================\n";
  11.     cout << "Welcome To \n";
  12.     cout << "Application Boiling Point of Several Substances\n";
  13.     cout << "================================================\n \n";
  14.  
  15.     cout << "Enter the value of boiling point : ";
  16.     cin >> value;
  17.  
  18.  
  19.     water = 100;
  20.     mercury = 357;
  21.     copper = 1187;
  22.     silver = 2193;
  23.     gold = 2660;
  24.  
  25.     water_p = water*5/100;
  26.     mercury_p = mercury*5/100;
  27.     copper_p = copper*5/100;
  28.     silver_p = silver*5/100;
  29.     gold_p = gold*5/100;
  30.  
  31.     if(value >= water-water_p && value <= water+water_p){
  32.         substance = "Water";
  33.     }else if(value >= mercury-mercury_p && value <= mercury+mercury_p){
  34.         substance = "Mercury";
  35.     }else if(value >= copper-copper_p && value <= copper+copper_p){
  36.         substance = "Copper";
  37.     }else if(value >= silver-silver_p && value <= silver+silver_p){
  38.         substance = "Silver";
  39.     }else if(value >= gold-gold_p && value <= gold+gold_p){
  40.         substance = "Gold";
  41.     }else{
  42.         cout << "Substance Unknown";
  43.         return 0;
  44.     }
  45.  
  46.     cout << "The value of boiling point is :" << substance;
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement