Write a program that will ask the user to enter the Atomic Number of an element and check if it is a precious metal according to the list below:
Atomic Number 47: Silver
Atomic Number 78: Platinum
Atomic Number 79: Gold
Output Possibility #1 (One of the three precious metals):
Enter an atomic number to see if it is a precious metal: [user types: 47]
47 is the atomic number for Silver
Output Possibility #2 (NOT a precious metal):
Enter an atomic number to see if it is a precious metal: [user types: 50]
50 is not an atomic number for a precious metal
#include <iostream>
using namespace std;
int main() {
int atomicNumber;
cout<<"Enter an atomic number to see if it is a precious metal: ";
cin>>atomicNumber;
if(atomicNumber==47){
cout<<atomicNumber<<" is the atomic number for Silver\n";
}else if(atomicNumber==78){
cout<<atomicNumber<<" is the atomic number for Platinum\n";
}else if(atomicNumber==79){
cout<<atomicNumber<<" is the atomic number for Gold\n";
}else{
cout<<atomicNumber<<" is not an atomic number for a precious metal\n\n";
}
system("pause");
return 0;
}
Comments
Leave a comment