Docstoc

5 6 T5 6 Yayi Wang 200905600

Document Sample
5 6 T5 6 Yayi Wang 200905600 Powered By Docstoc
					          T5.6

Yayi Wang 200905600 INFO
//T5.6
#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
      double total=0.0,
money1=0.0,money2=0.0,money3=0.0,money4=0.0,money5=0.0;
      int product, quantity;

      cout<<"Enter product number(1-5)(-1 to stop): ";
      cin>>product;
      cout<<fixed<<setprecision(2);


      while(product!=-1)
      {
            cout<<"Enter quantity sold: ";
          cin>>quantity;

            switch(product)
            {
            case 1:
                  money1=quantity*2.98;
                  total=total+quantity*2.98;
                  break;

            case 2:
                  money2=quantity*4.50;
                  total=quantity*4.50+total;
                  break;
            case 3:
                  money3=quantity*9.98;
                  total=quantity*9.98+total;
                  break;
            case 4:
                  money4=quantity*4.49;
                  total=quantity*4.49+total;
                  break;
            case 5:
                  money5=quantity*6.87;
                  total=quantity*6.87+total;
                  break;
            }
            cout<<"Enter product number(1-5)(-1 to stop): ";
          cin>>product;

      }

      cout<<"\nproduct1: $"<<money1;
      cout<<"\nproduct2: $"<<money2;
      cout<<"\nproduct3: $"<<money3;
      cout<<"\nproduct4: $"<<money4;
      cout<<"\nproduct5: $"<<money5;
      cout<<"\nTotal: $"<<total;

      return 0;
}




//5.7 part1
#include<iostream>
using namespace std;

int main()
{
      int x,y,a,b,g,i,j;

      cout<<"Enter x(-10 to quit): ";
      cin>>x;
      while(x!=-10)
      {
          cout<<"enter y: ";
          cin>>y;

          cout<<boolalpha;
            cout<<"!(x<5): "<<(!(x<5));
            cout<<"\n!(y>=7): "<<(!(y>=7));
            if((!(x<5)&&!(y>=7))==(!((x<5)||(y>=7))))
                  cout<<"\n!(x<5)&&!(y>=7) is euivalent to !((x<5)||(y>=7))";
            cout<<"\nEnter x(-10 to quit): ";
          cin>>x;
      }
      return 0;
}


//5.7 part2
#include<iostream>
using namespace std;

int main()
{
      int x,y,a,b,g,i,j;

      cout<<"\nEnter a(-10 to quit): ";
      cin>>a;
      while(a!=-10)
      {

          cout<<"enter b: ";
          cin>>b;
            cout<<"enter g: ";
          cin>>g;

          cout<<boolalpha;
            cout<<"\n!(a==b) "<<(!(a==b));
            cout<<"\n!(g!=5) "<<(!(g!=5));
            if((!(a==b)&&!(g!=5))==(!((a==b)||(g!=5))))
                  cout<<"\n!(a==b)&&!(g!=5) is euivalent to
!((a==b)||(g!=5))";
            cout<<"\nEnter a(-10 to quit): ";
          cin>>a;
      }
      return 0;
}



//5.7 part3
#include<iostream>
using namespace std;

int main()
{
      int x,y,a,b,g,i,j;

      cout<<"Enter x(-10 to quit): ";
      cin>>x;
      while(x!=-10)
      {

          cout<<"enter y: ";
          cin>>y;

          cout<<boolalpha;
            cout<<"!((x<=8): "<<(!((x<=8)));
            cout<<"\n(y>4): "<<((y>4));
            if((!((x<=8)&&(y>4)))==(!(x<=8)||!(y>=4)))
                   cout<<"\n!((x<=8)&&(y>4)) is euivalent to
!(x<=8)||!(y>=4)";
            cout<<"\nEnter x(-10 to quit): ";
          cin>>x;
      }
      return 0;
}


//5.7 part4
#include<iostream>
using namespace std;

int main()
{
      int x,y,a,b,g,i,j;

      cout<<"Enter i(-10 to quit): ";
      cin>>i;
      while(i!=-10)
      {

          cout<<"enter j: ";
          cin>>j;

          cout<<boolalpha;
            cout<<"(i>4): "<<((i>4));
            cout<<"\n(j<=6): "<<((j<=6));
            if((!((i>4)||(j<=6)))==(!(i>4)&&!(j<=6)))
                  cout<<"\n!((i>4)||(j<=6)) is euivalent to !(i>4)&&!(j<=6)";
            cout<<"\nEnter i(-10 to quit): ";
          cin>>i;
      }
      return 0;
}

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:2
posted:2/19/2012
language:
pages:6