Nee help for me project plez...
welll sorry for it..
i need to figure how it's done...
this is a program that takes a measurement in one unit (e.g., 4.5 miles, etc) and converts it to another unit (i.e. kilometers).
the algorithm is
The algorithm for the program is fairly straightforward.
1
. Load units of measurement database.
2.
Get value to convert and old and new unit names.
3.
Repeat until data format error encountered.
4.
Search for old unit in database.
5.
Search for new units in database.
6.
If conversion is impossible, issue appropriate message,
7.
Else, compute and display conversion
8.
Get value to convert an old and new unit names..
and then the unit.dat
is
Help with Code Tags (Toggle Plain Text)
kilometers km distance 1000
yards yd distance 0.9144
meters m distance 1
quarts qt volume 0.94635
liters l volume 1
gallons gal volume 3.7854
milliliters ml volume 0.001
kilograms kg mass 1
grams g mass 0.001
slugs slugs mass 0.14594
my code is this
ikilometers km distance 1000
yards yd distance 0.9144
meters m distance 1
quarts qt volume 0.94635
liters l volume 1
gallons gal volume 3.7854
milliliters ml volume 0.001
kilograms kg mass 1
grams g mass 0.001
slugs slugs mass 0.14594
my code is this
i
well how to search and display the error when have found the target??any ideas??
any ideas on the repeat data format until error found???
i have no idea...so and search for old and new units..
i m stuck...
Code:
#include <stdio.h>
void calculate conversion(double input)
char input_oldunit;
double input_value;
char input_newunit;
struct unit
4{
char oldunit[12];
char SI [5];
char newunit[10];
double value;
};
int main()
{
struct unit h[20];
int k = 0.0;
char choice
FILE *measurement;
printf("\THIS IS A UNIVERSAL MEASUREMENT PROGRAMn");
measurement = fopen("unit.dat","r");
do{
printf("\nPlease select q to quit or other to enter conversion program:");
scanf("%s",&choice);
printf("You have selected option %d\n\n",choice);
switch(choice)
{
case q:
printf("thank s and have a nice day\n);
return 0;
break;
}
default:{
if (measurement == NULL)
printf("Error opening data file.\n");
else
{
while(fscanf(measurement,"%s %s %s %lf ",&h1[k].oldunit,&h1[k].SI,&h1[k].newunit,&h1[k].value)==4)
{
printf(" input your values followed with it's measurement name or SI unit and the target measurement's name or SI unit.\n");
scanf(" %lf %s %s",&input_value,&input_oldunit,&input_newunit);
calculate conversion(input);
}
}
}
fclose(measurement);
}
printf("If you want to quit, press q or else press any key to continue\n");
scanf("%s",&choice);
}while(optn!=q);
printf("To the infinite..and BEYOND....!!!!!\n\n");
break;
return;
}
#include <stdio.h>
void calculate conversion(double input)
char input_oldunit;
double input_value;
char input_newunit;
struct unit
4{
char oldunit[12];
char SI [5];
char newunit[10];
double value;
};
int main()
{
struct unit h[20];
int k = 0.0;
char choice
FILE *measurement;
printf("\THIS IS A UNIVERSAL MEASUREMENT PROGRAMn");
measurement = fopen("unit.dat","r");
do{
printf("\nPlease select q to quit or other to enter conversion program:");
scanf("%s",&choice);
printf("You have selected option %d\n\n",choice);
switch(choice)
{
case q:
printf("thank s and have a nice day\n);
return 0;
break;
}
default:{
if (measurement == NULL)
printf("Error opening data file.\n");
else
{
while(fscanf(measurement,"%s %s %s %lf ",&h1[k].oldunit,&h1[k].SI,&h1[k].newunit,&h1[k].value)==4)
{
printf(" input your values followed with it's measurement name or SI unit and the target measurement's name or SI unit.\n");
scanf(" %lf %s %s",&input_value,&input_oldunit,&input_newunit);
calculate conversion(input);
}
}
}
fclose(measurement);
}
printf("If you want to quit, press q or else press any key to continue\n");
scanf("%s",&choice);
}while(optn!=q);
printf("To the infinite..and BEYOND....!!!!!\n\n");
break;
return;
}
well i