6. Program that accepts the code number as an input and display the correct disk drive manufacture.

Chapter 5: 

Conditional Structures

Programming Exercise

Problem # 6:

Write a program that accepts the code number as an input and display the correct disk drive manufacture as follows:
Code        disk drive manufacture
1            Western Digital
2            3M Corporation
3            Maxell Corporation
4            Sony Corporation
5            Verbatim Corporation

Solution:

#include<iostream.h>
#include<conio.h>
using namespace std;
int main ()
{
    int cd;
    cout<<"Enter code for disk drive manufacturer:";
    cin>>cd;
    switch(cd)
    {
        case 1:
            cout<<"\nThe disk drive manufacturer is Western Digital.";
            break;
        case 2:
            cout<<"\nThe disk drive manufacturer is 3M Corporation.";
            break;
        case 3:
            cout<<"\nThe disk drive manufacturer is Maxell Corporation.";
            break;
        case 4:
            cout<<"\nThe disk drive manufacturer is Sony Corporation.";
            break;
        case 5:
            cout<<"\nThe disk drive manufacturer is Verbatim Corporation.";
            break;
        default:
            cout<<"Invalid input.";
    }
    return 0;
}


Let me know in the comment section if you have any question.

Previous Post:
5. Program that gets the number and a letter. If the letter is 'f', convert it to the temperature in degree Celsius. If the letter is 'c', convert it to Fahrenheit temperature.

Comments