السلام عليكــم ورحمـة الله وبركاتــه
الفريق العربي للبرمجة
اتمنىىىىىىىى مساعدتى وتصحيح الاخطاء
في خرآئط رقمية عن آلمۈآقع في شمآل خط آلعرض / خط آلطۈل ۈجنۈب غرب / شرق. على سبيل آلمثآل مڪة آلمڪرمة هۈ في مۈقع 39 درجة شرق خط آلطۈل 22.7 دقيقة ۈ 21 درجة شمآل خط آلعرض 40.5 دقيقة. هذآ هۈ مڪٺۈب على آلنحۈ 22.7 ° 39 'شرقآ 40.5 ° 21' شمآلآ. ۈهنآڪ 60 دقيقة في درجة. آلطۈل يقآس من 0 إلى 180 درجة شرقآ أۈ من غرب غرينٺش ، آنجلٺرآ ، إلى آلمصدر آلدۈلية في منطقة آلمحيط آلهآدئ. ڪٺآبة آلبرنآمج مرآرآ ۈٺڪرآرآ أن يطلب آلمسٺخدم لدخۈل معلۈمآٺ عن آلمۈقع : عن خط آلطۈل : درجة ، دقيقة ، ۈآلآٺجآه. بعد أن برنآمجڪ يجب طبآعة هذه آلمعلۈمآٺ في آلشڪل آلٺآلي : 40.5 ° 21 'شرقآ. ۈإذآ ڪآن آلمسٺخدم يدخل قيمة غير صحيحة لدرجة ، آلطۈل ، يآ آلبرنآمج ينبغي أن يطلب منه مرآرآ ۈٺڪرآرآ لدخۈل صآلحة ۈآحدة
Exercise #1 :
In digital maps locations are expressed in latitude North/South and longitude West/East. For example Makkah Al Mukarramah is at location 39 degrees 22.7 minutes east longitude and 21 degrees 40.5 minutes north latitude. This is written as 39° 22.7’ EAST, 21° 40.5’NORTH. There are 60 minutes in a degree. Longitude is measured from 0 to 180 degrees east or west from Greenwich, England, to the international dateline in the Pacific. Write a program that repeatedly ask a user to enter information about a location: its longitude : Degree, minutes, and direction. After that your program should print this information in the following format: 21° 40.5’ EAST. If the user enters a non valid value for degree, longitude, Your program should repeatedly ask him to enter a valid one.
Technical Details:
§ Use enum
§ Use structure
Your program output should be something like this:
Do You Want to Enter a Location :
enter N to exit, Y to continue
y
Enter a longitude
Enter a degree of this location : 0 - 180
190
Please enter a valid value : 0-180
170
Enter a minute of this location : 0 -60
90
Please enter a valid value : 0-60
35
What is a Direction ?
e. East
w. West
e
Your location is :
170 35 East
Do You Want to Enter a Location :
enter N to exit, Y to continue
n
Thank you for using my program
هذا هوا السؤال
v
v
هذل ما قمت انا بكتابته ولكن وجد اخطاء
# include <iostream>
using namespace std;
enum Direction {North,East,West,South};
struct location {int Degree ;
float minutes ;
Direction dir ;
};
int main ()
{
location loc;
char dir_char;
cout<<"Do You Want to Enter a Location :"<<endl;
cout<<" enter N to exit, Y to continue "<<endl;
cin>>choice;
while (choice=='y')
{
cout<<"Enter a longitude "<<endl;
cout<<"Enter a degree of this location : 0 - 180"<<endl;
cin >> Degree ;
if (Degree>180){
cout<< "\nPlease enter a valid value : 0-180 "<<endl;
cin>>Degree;
else
cout<<"\nEnter a minute of this location : 0 -60"<<endl;
cin>>minutes;}
if (minutes>60){
cout<<"\nPlease enter a valid value : 0-60 "<<endl;
cin>>>minutes;
else
cout<<"\nWhat is a Direction ? "<<endl;}
cout<<"\nn.North"<<"\ne.East"<<"\nw.West"<<"\ns.South"<<endl;
cin>>dir_char;{
if((dir_char=='n')||(dir_char=='N'))
loc.dir=North;
else if((dir_char=='e')||(dir_char=='E'))
loc.dir=East;
else if((dir_char=='w')||(dir_char=='W'))
loc.dir=West;
else if((dir_char=='s')||(dir_char=='S'))
loc.dir=South;
cout<<"\nPlease enter a valid leetr";
}
cout<<"\nYour location is : "<<endl;
cout<<Degree<<minutes<<dir_char<<endl;
cout<<" Do You Want to Enter a Location :";
cout<<"\n enter N to exit, Y to continue ";
cin>>choice;
}
cout<<"\nThank you for using my program "<<endl;
return 0;
}
Do You Want to Enter a Location :
enter N to exit, Y to continue
y
Enter a longitude
Enter a degree of this location : 0 - 180
190
Please enter a valid value : 0-180
170
Enter a minute of this location : 0 -60
90
Please enter a valid value : 0-60
35
What is a Direction ?
e. East
w. West
e
Your location is :
170 35 East
Do You Want to Enter a Location :
enter N to exit, Y to continue
n
Thank you for using my program