Pages

Tuesday, October 22, 2013

zodiac sign code in c++

using if and else if
here's the code in making a zodiac in c++:

# include <iostream>
using namespace std;
int main ()
{
    int month, date;
    cout<<"Enter your numerical month: "; cin>>month; cout<<endl;
    cout<<"Enter your numerical date: "; cin>>date; cout<<endl;
    if (month == 3 && date >= 21 || month == 4 && date <= 20)
    { cout<<"Your sign is Aries"; cout<<endl;}
    else if (month == 4 && date >= 21 || month == 5 && date <= 21)
    { cout<<"Your sign is Taurus"; cout<<endl;}
    else if (month == 5 && date >= 22 || month == 6 && date <= 22)
    { cout<<"Your sign is Gemini"; cout<<endl;}
    else if (month == 6 && date >= 23 || month == 7 && date <= 23)
    { cout<<"Your sign is Cancer"; cout<<endl;}
    else if (month == 7 && date >= 24 || month == 8 && date <= 23)
    { cout<<"Your sign is Leo"; cout<<endl;}
    else if (month == 8 && date >= 24 || month == 9 && date <= 23)
    { cout<<"Your sign is Virgo"; cout<<endl;}
    else if (month == 9 && date >= 24 || month == 10 && date <= 23)
    { cout<<"Your sign is Libra"; cout<<endl;}
    else if (month == 10 && date >= 24 || month == 11 && date <= 22)
    { cout<<"Your sign is Scorpio"; cout<<endl;}
    else if (month == 11 && date >= 24 || month == 12 && date <= 21)
    { cout<<"Your sign is Saguittarius"; cout<<endl;}
    else if (month == 12 && date >= 22 || month == 1 && date <= 20)
    { cout<<"Your sign is Capricorn"; cout<<endl;}
    else if (month == 1 && date >= 21 || month == 2 && date <= 19)
    { cout<<"Your sign is Aquarius"; cout<<endl;}
    else if (month == 2 && date >= 20 || month == 3 && date <= 20)
    { cout<<"Your sign is Pieces"; cout<<endl;}
    cout<<endl;
    system ("pause");
}


This will be the output:


Sunday, October 20, 2013

Passed or Failed Grade code in c++

This will be the output:
if passed:


if failed:





This will be the code:
# include <iostream>
using namespace std;
int main ()
{
    int score;
    cout<<"Enter your score: "; cin>>score; cout<<endl;
    if (score >= 90)
    {
        cout<<"You got an A*"; cout<<endl;
        cout<<"You Passed"; cout<<endl;
    }
    else if (score >= 80)
    {
        cout<<"You got an A"; cout<<endl;
        cout<<"You Passed"; cout<<endl;
    }
    else if (score >= 70)
    {
        cout<<"You got a B*"; cout<<endl;
        cout<<"You Passed"; cout<<endl;
    }
    else if (score >= 60)
    {
        cout<<"You got a C"; cout<<endl;
        cout<<"You Passed"; cout<<endl;
    }
    else if (score >= 50)
    {
        cout<<"You got a D"; cout<<endl;
        cout<<"You Passed"; cout<<endl;
    }
    else if (score >= 40)
    {
        cout<<"You got a D"; cout<<endl;
        cout<<"You Failed"; cout<<endl;
    }
    else if (score >= 30)
    {
        cout<<"You got a E"; cout<<endl;
        cout<<"You Failed"; cout<<endl;
    }
    else if (score >= 20)
    {
        cout<<"You got a F"; cout<<endl;
        cout<<"You Failed"; cout<<endl;
    }
    else if (score >= 10)
    {
        cout<<"You got a G"; cout<<endl;
        cout<<"You Failed"; cout<<endl;
    }
    else if (score >= 1)
    {
        cout<<"You got a H"; cout<<endl;
        cout<<"You Failed"; cout<<endl;
    }
    cout<<endl;
    system ("pause");
}
.post {-webkit-user-select: none; -khtml-user-select: none; -moz-user-select: -moz-none; -ms-user-select: none; user-select: none;}

Tuesday, October 8, 2013

Gross bill code in c++

Pizzarita Pizza House charges 10% Service 4% sales tax on the gross bill of its customers. Make a program that would input the gross bill of the customer and the amount given by the customer to the waiter. Program must output the customer's total bill and his charge.

This will be the output









Here's the code:

# include <iostream>
using namespace std;
int main ()
{
    float a=0, b=0;
    cout<<"Pizarita House"; cout<<endl;
    cout<<"Enter Gross Bill: "; cin>>a;
    cout<<"Service Tax: "; cout<<0.10<<endl;
    cout<<"Sales Tax: "; cout<<0.04<<endl;
    cout<<"Total Bill: "; cout<<a+(a*0.14); cout<<endl;
    cout<<"Amount Bill: "; cin>>b;
    cout<<"Change: "; cout<<b-(a+(a*0.14));
    cout<<endl;
    system ("pause");
}

That's all. Enjoy:)


Monday, October 7, 2013

Enter 3-digit code in c++

This will be the output:
Enter 3-digit: 123
First Digit: 1
Second Digit: 2
Last Digit: 3
The reverse value: 321

This is the code

# include <iostream>
using namespace std;
int main ()
{
int a=0, b=0, c=0, d=0;
cout<<"Enter 3-digit:"; cin>>d;
a=d/100;
b=(d-(a*100))/10;
c=d-((a*100)+(b*10));
cout<<endl;
cout<<"First Digit:"; cout<<a;
cout<<"Second Digit:"; cout<<b;
cout<<"Last Digit:"; cout<<c;
cout<<"The Reverse Value:"; cout<<c&&cout<<b&&cout<<a;
cout<<endl;
system ("pause");
}


Sunday, October 6, 2013

The Reverse Digit in c++

This is the 1st activity we did in our school. The Reverse Digit digit, you will input 3 integer and the output comes in reverse.

# include <iostream>
using namespace std;
int main ()
{
int x=0, y=0, z=0, a=0;
cout<<"Enter First Digit:"; cin>>x;
cout<<"Enter Second Digit:"; cin>>y;
cout<<"Enter Last Digit:"; cin>>z;
cout<<"The Reverse Value:" <<z<<y<<x;
cout<<endl;
system ("pause");
}

This is the output:
Enter First Digit:5
Enter Second Digit:4
Enter Last Digit:3
The Reverse Value: 345