Wednesday, February 23, 2011

#4 Struct vezba automobil,motor,sasija,elektrika, mehanika

#include<stdio.h>
#include<conio.h>
#include<math.h>
//made by student Caric Stefan
void main(){

  struct s_elektrika{
  unsigned char akumulator[10];
  unsigned char sijalica[10];
  };

  struct s_mehanika{
  unsigned char klima[5];
  unsigned char radio[5];
  unsigned char elPodizaci[5];
  unsigned char GPS[5];
  };

 struct s_motor {
unsigned char modelMotora[5];
unsigned int godProizvodnje;
unsigned char tip[20];
};

struct s_automobil{
char model[10];
int godProizvodnja;
char boja[10];
char marka[15];
char uslovM[10];
struct s_motor motor;
struct s_mehanika mehanika;
struct s_elektrika elektrika;
};

struct s_automobil automobil;

 char uslov;



  clrscr();
   printf("Program koji pravi strukturu automobil i izbacuje vec ponudjene podatke\n\n");



printf("Unesit podatke vezane za automobil \n");
printf("+-----------+-------+\n");
printf("| MARKA     | USLOV |\n");
printf("+-----------+-------+\n");
printf("| Audi      |  A    |\n"); printf("| BMW       |  B    | \n");  printf("| Opel      |  O    |\n"); printf("| Mercedes  |  M    |\n");
printf("+-----------+-------+\n");
printf("\n");
printf("Uslov: ");scanf("%c",&uslov);printf("\n");
printf("Marka: "); scanf("%s",&automobil.marka);printf("\n");

switch (uslov=='A'){
case 1:
{
char uslovA;

printf("Modeli automobila marke Audi:\n");
printf("A4\n");printf("A6\n");
printf("------------------------\n");
printf("Model: "); scanf("%s",&automobil.uslovM);printf("\n");
printf("------------------------\n");
printf("Godine proizvodnje:\n");
printf("2006 \n"); printf("2008 \n");
printf("------------------------\n");
printf("Godina proizvodnje: ");scanf("%d",&automobil.godProizvodnja);printf("\n");
printf("------------------------\n");
printf("Boja modela \n");
printf("------------------------\n");
printf("Crna boja\n");printf("Bela boja\n");printf("Crvena boja\n");printf("Plava boja\n");
printf("------------------------\n");
printf("Boja: "); scanf("%s",&automobil.boja);printf("\n");
printf("------------------------\n");
printf("Tipovi motora:\n ");
printf("------------------------\n");
printf("Dizel\n");printf("Benzin\n");
printf("------------------------\n");
printf("Tip motora: "); scanf("%s",&automobil.motor.tip);printf("\n");
printf("------------------------\n");
printf("Modeli motora:\n");
printf("1.8\n");printf("2.0\n");printf("2.2\n");
printf("------------------------\n");
printf("Model motora: ");scanf("%s",&automobil.motor.modelMotora);printf("\n");
printf("------------------------\n");
printf("Godina proizvodnje motora\n");
printf("2006 \n"); printf("2008 \n");
printf("------------------------\n");
printf("Godina proizvodnje: "); scanf("%d",&automobil.motor.godProizvodnje);printf("\n");
printf("------------------------\n");
printf("Podaci vezani za mehaniku\n");
printf("Klima: ");scanf("%s",&automobil.mehanika.klima);printf("\n");
printf("Radio: ");scanf("%s",&automobil.mehanika.radio);printf("\n");
printf("GPS: ");scanf("%s",&automobil.mehanika.GPS);printf("\n");
printf("Elektricni podizaci: ");scanf("%s",&automobil.mehanika.elPodizaci);printf("\n");
printf("Podaci vezani za elektriku\n");
printf("Akumulator: ");scanf("%s",&automobil.elektrika.akumulator);printf("\n");
printf("Sijalica: ");scanf("%s",&automobil.elektrika.sijalica);printf("\n");
break;
}
}
switch (uslov=='B'){
case 1:
{
char uslovA;

printf("Modeli automobila marke BMW:\n");
printf("X3\n");printf("X5\n");printf("Z4\n");
printf("------------------------\n");
printf("Model: "); scanf("%s",&automobil.uslovM);printf("\n");
printf("------------------------\n");
printf("Godine proizvodnje:\n");
printf("2008 \n"); printf("2009 \n");
printf("------------------------\n");
printf("Godina proizvodnje: ");scanf("%d",&automobil.godProizvodnja);printf("\n");
printf("------------------------\n");
printf("Boja modela \n");
printf("------------------------\n");
printf("Crna boja\n");printf("Bela boja\n");printf("Crvena boja\n");printf("Plava boja\n");
printf("------------------------\n");
printf("Boja: "); scanf("%s",&automobil.boja);printf("\n");
 printf("------------------------\n");
 printf("Tipovi motora:\n ");
 printf("------------------------\n");
 printf("Dizel\n");printf("Benzin\n");
 printf("------------------------\n");
printf("Tip motora: "); scanf("%s",&automobil.motor.tip);printf("\n");
printf("------------------------\n");
printf("Modeli motora:\n");
printf("2.0\n");printf("4.0\n");printf("4.2\n");
printf("------------------------\n");
printf("Model motora: ");scanf("%s",&automobil.motor.modelMotora);printf("\n");
printf("------------------------\n");
printf("Godina proizvodnje motora\n");
printf("2008 \n"); printf("2009 \n");
printf("------------------------\n");
printf("Godina proizvodnje: "); scanf("%d",&automobil.motor.godProizvodnje);printf("\n");
printf("------------------------\n");
printf("Podaci vezani za mehaniku\n");
printf("Klima: ");scanf("%s",&automobil.mehanika.klima);printf("\n");
printf("GPS: ");scanf("%s",&automobil.mehanika.GPS);printf("\n");
printf("Radio: ");scanf("%s",&automobil.mehanika.radio);printf("\n");
printf("Elektricni podizaci: ");scanf("%s",&automobil.mehanika.elPodizaci);printf("\n");
printf("Podaci vezani za elektriku\n");
printf("Akumulator: ");scanf("%s",&automobil.elektrika.akumulator);printf("\n");
printf("Sijalica: ");scanf("%s",&automobil.elektrika.sijalica);printf("\n");
break;
}
}
switch (uslov=='O'){
case 1:
{
char uslovA;

printf("Modeli automobila marke Opel:\n");
printf("Astra\n");printf("Corsa\n");printf("Insignia\n");
printf("------------------------\n");
printf("Model: "); scanf("%s",&automobil.uslovM);printf("\n");
printf("------------------------\n");
printf("Godine proizvodnje:\n");
printf("2008 \n"); printf("2009 \n");printf("2010\n");
printf("------------------------\n");
printf("Godina proizvodnje: ");scanf("%d",&automobil.godProizvodnja);printf("\n");
printf("------------------------\n");
printf("Boja modela \n");
printf("------------------------\n");
printf("Crna boja\n");printf("Bela boja\n");printf("Crvena boja\n");printf("Plava boja\n");
printf("------------------------\n");
printf("Boja: "); scanf("%s",&automobil.boja);printf("\n");
 printf("------------------------\n");
 printf("Tipovi motora:\n ");
 printf("------------------------\n");
 printf("Dizel\n");printf("Benzin\n");
 printf("------------------------\n");
printf("Tip motora: "); scanf("%s",&automobil.motor.tip);printf("\n");
printf("------------------------\n");
printf("Modeli motora:\n");
printf("1.7\n");printf("2.0\n");printf("2.2\n");
printf("------------------------\n");
printf("Model motora: ");scanf("%s",&automobil.motor.modelMotora);printf("\n");
printf("------------------------\n");
printf("Godina proizvodnje motora\n");
printf("2008 \n"); printf("2009 \n");printf("2010\n");
printf("------------------------\n");
printf("Godina proizvodnje: "); scanf("%d",&automobil.motor.godProizvodnje);printf("\n");
printf("------------------------\n");
printf("Podaci vezani za mehaniku\n");
printf("Klima: ");scanf("%s",&automobil.mehanika.klima);printf("\n");
printf("GPS: ");scanf("%s",&automobil.mehanika.GPS);printf("\n");
printf("Radio: ");scanf("%s",&automobil.mehanika.radio);printf("\n");
printf("Elektricni podizaci: ");scanf("%s",&automobil.mehanika.elPodizaci);printf("\n");
printf("Podaci vezani za elektriku\n");
printf("Akumulator: ");scanf("%s",&automobil.elektrika.akumulator);printf("\n");
printf("Sijalica: ");scanf("%s",&automobil.elektrika.sijalica);printf("\n");
break;
}
}
switch (uslov=='M'){
case 1:
{
char uslovA;

printf("Modeli automobila marke Mercedes:\n");
printf("A-class\n");printf("B-class\n");printf("C-class\n");
printf("------------------------\n");
printf("Model: "); scanf("%s",&automobil.uslovM);printf("\n");
printf("------------------------\n");
printf("Godine proizvodnje:\n");
printf("2009 \n"); printf("2010 \n");printf("2011\n");
printf("------------------------\n");
printf("Godina proizvodnje: ");scanf("%d",&automobil.godProizvodnja);printf("\n");
printf("------------------------\n");
printf("Boja modela \n");
printf("------------------------\n");
printf("Crna boja\n");printf("Bela boja\n");printf("Crvena boja\n");printf("Plava boja\n");
printf("------------------------\n");
printf("Boja: "); scanf("%s",&automobil.boja);printf("\n");
 printf("------------------------\n");
 printf("Tipovi motora:\n ");
 printf("------------------------\n");
 printf("Dizel\n");printf("Benzin\n");
 printf("------------------------\n");
printf("Tip motora: "); scanf("%s",&automobil.motor.tip);printf("\n");
printf("------------------------\n");
printf("Modeli motora:\n");
printf("2.0\n");printf("2.2\n");printf("4.0\n");printf("4.2\n");
printf("------------------------\n");
printf("Model motora: ");scanf("%s",&automobil.motor.modelMotora);printf("\n");
printf("------------------------\n");
printf("Godina proizvodnje motora\n");
printf("2009 \n"); printf("2010 \n"); printf("2011\n");
printf("------------------------\n");
printf("Godina proizvodnje: "); scanf("%d",&automobil.motor.godProizvodnje);printf("\n");
printf("------------------------\n");
printf("Podaci vezani za mehaniku\n");
printf("Klima: ");scanf("%s",&automobil.mehanika.klima);printf("\n");
printf("GPS: ");scanf("%s",&automobil.mehanika.GPS);printf("\n");
printf("Radio: ");scanf("%s",&automobil.mehanika.radio);printf("\n");
printf("Elektricni podizaci: ");scanf("%s",&automobil.mehanika.elPodizaci);printf("\n");
printf("Podaci vezani za elektriku\n");
printf("Akumulator: ");scanf("%s",&automobil.elektrika.akumulator);printf("\n");
printf("Sijalica: ");scanf("%s",&automobil.elektrika.sijalica);printf("\n");
break;
}
default:
{
printf("Nema tog uslova \n");printf("\n");
break;
}
}
printf("Ispis \n");
printf("-------------------------------------------\n");
printf("Ispis podataka vezan za strukturu Automobila \n");
printf("-------------------------------------------\n");
printf("Marka: %s \n",automobil.marka);
printf("Model: %s \n",automobil.uslovM);
printf("Godina proizvodnje: %d \n",automobil.godProizvodnja);
printf("Boja: %s \n",automobil.boja);
printf("-------------------------------------------\n");
printf("Podaci vezani za motor\n");
printf("-------------------------------------------\n");
printf("Tip motora: %s \n",automobil.motor.tip);
printf("Model motora: %s \n",automobil.motor.modelMotora);
printf("Godina proizvodnje: %d \n",automobil.motor.godProizvodnje);
printf("-------------------------------------------\n");
printf("Podaci vezani za Mehaniku\n");
printf("-------------------------------------------\n");
printf("Klima: %s \n",automobil.mehanika.klima);
printf("GPS: %s ",automobil.mehanika.GPS);printf("\n");
printf("Radio: %s \n",automobil.mehanika.radio);
printf("Elektricni podizaci: %s \n",automobil.mehanika.elPodizaci);
printf("-------------------------------------------\n");
printf("Podaci vezani za elektroniku\n");
printf("-------------------------------------------\n");
printf("Akumulator: %s",automobil.elektrika.akumulator);printf("\n");
printf("Sijalica: %s",automobil.elektrika.sijalica);printf("\n");


getch();
}

No comments:

Post a Comment