Hello there,
so i have this current project for school and i`m kinda stuck the program i`m suppose to write is this :
__________________________________________________ ____
Each year many tourist visit our country please write a program that collect the following information:
Name(first,middle,last)
sex
country
age
profession
Also the program shoud be bale to print out the following information on request:
1.What is the average age of the tourists visited
2. What is the name the age and the profession of the youngest women visited
3.what countries we had visitors from
4. from what country we got most visits
__________________________________________________ ____
Ok so far i`m this far and i`m kinda lost so if anyone can help me i will be very happy Thank you for all of your help in advance!
PS:i know it is a mess i`m kinda new to this
#include <iostream>
#include <cctype>
#include <string>
using namespace std;
void average_age(char x[][20]);
void youngest_women();
const int count=10;
int main()
{
char Fname[count][20];
char Sname[count][20];
char Lname[count][20];
char sex[count][20];
char country[count][20];
int age[count];
char profesion[count][20];
int x;
for(int i=0;i<=count;i++){
cout<<"Enter the First name of the tourist"<< endl;
cin>>Fname[i];
cout<<"Enter the Surname of the tourist"<< endl;
cin>>Sname[i];
cout<<"Enter the Family name of the tourist"<< endl;
cin>>Lname[i];
cout<<"Enter the sex of the tourist(m/f):"<< endl;
sex: cin>>sex[i];
if (sex[i] != "m"){
if (sex[i] != "f")goto sex;
}
cout<<"Enter the coutry the tourist is from"<< endl;
cin>>country[i];
country[i] = toupper(country[i]);
cout<<"Enter the age of the tourist"<< endl;
cin>>age[i];
cout<<"Enter the proffession of the tourist"<< endl;
cin>>profesion[i];
}
cout<<"What information would you like to know about our tourists?"<< endl;
cout<<"1.What is the average age of the tourists visited Bulgaria?"<< endl;
cout<<"2.What is the name of the youngest women visited Bulgaria?"<< endl;
cout<<"3.From wich countries we got tourists this year?"<< endl;
cout<<"Please chose from 1-3"<< endl;
cin>>x;
switch (x)
{
case 1: average_age(age[10][20]);break;
case 2: youngest_women();break;
case 3: country_list();break;
default: cout<<"Error";
}
return 0;
}
void average_age(char x[][20])
{
int average=0;
for(int i=0;i<=count;i++)
average +=age[i];
cout<< "The average age of the tourists is: "<<average<< " years"<< endl;
}
void youngest_women()
{
int m=0,y=0;
for(int i=0;i<=count;i++){
if (y>age[i]){
if (sex=='f'){
y=age[i];
m=i;
}
}
}
cout<<"The youngest women visited Bulgaria is: " <<Fname[m]<<" "<<Sname[m]<<" "<<Lname[m]<<" at age of "<<age[m]<<" from "<<country[i]<<endl;
}
void country_list()
{
int a[150] = {0, 0};
char list[][20]{AFGHANISTAN, ALBANIA, ALGERIA ,ANDORRA, ANGOLA, ARGENTINA, ARMENIA, AUSTRALIA, AUSTRIA, AZERBAIJAN, BAHAMAS, BAHRAIN, BANGLADESH, BARBADOS, BELARUS,
BELGIUM, BELIZE, BENIN, BHUTAN, BOLIVIA, BOTSWANA, BRAZIL, BRUNEI, USA, BURKINA, BURUNDI, CAMBODIA, CAMEROON, CANADA, CHAD, CHILE, CHINA, COLOMBIA, COMOROS, CONGO,
CROATIA, CUBA, CYPRUS, DENMARK, DJIBOUTI, DOMINICA, ECUADOR, EGYPT, ERITREA, ESTONIA, ETHIOPIA, FIJI, FINLAND, FRANCE, GABON, GAMBIA, GEORGIA, GERMANY, GHANA, GREECE,
GRENADA, GUATEMALA, GUINEA, GUYANA, HAITI, HONDURAS, HUNGARY, ICELAND, INDIA, INDONESIA, IRAN, IRAQ, IRELAND, ISRAEL, ITALY, JAMAICA, JAPAN, JORDAN, KAZAKHSTAN, KENYA,
KIRIBATI, KOSOVO, KUWAIT, KYRGYZSTAN, LAOS, LATVIA, LEBANON, LESOTHO, LIBERIA, LIBYA, LIECHTENSTEIN, LITHUANIA, LUXEMBOURG, MACEDONIA, MADAGASCAR, MALAWI, MALAYSIA, MALDIVES,
MALI, MALTA, MAURITANIA, MAURITIUS, MEXICO, MICRONESIA, MOLDOVA, MONACO, MONGOLIA, MONTENEGRO, MOROCCO, MOZAMBIQUE, MYANMAR, NAMIBIA, NAURU, NEPAL, NETHERLANDS, NICARAGUA, NIGER,
NIGERIA, NORWAY, OMAN, PAKISTAN, PALAU, PANAMA, PARAGUAY, PERU, PHILIPPINES, POLAND, PORTUGAL, QATAR, ROMANIA, RWANDA, SAMOA, SENEGAL, SERBIA, SEYCHELLES, SINGAPORE, SLOVAKIA,
SLOVENIA, SOMALIA, SPAIN, SUDAN, SURINAME, SWAZILAND, SWEDEN, SWITZERLAND, SYRIA, TAIWAN, TAJIKISTAN, TANZANIA, THAILAND, TOGO, TONGA, TUNISIA, TURKEY, TURKMENISTAN, TUVALU,
UGANDA, UKRAINE, URUGUAY, UZBEKISTAN, VANUATU, VENEZUELA, VIETNAM, YEMEN, ZAMBIA, ZIMBABWE}
for(int i=0; i<=count; i++){
for(int n=0; n<=150; n++){
if(strcmp(country[i],list[n]) == 0){
a[n] += 1;
break;
}
}
}
for(int i=0; i<=150; i++){
if(a[i] != 0){
cout<<list[i]<<" - "<<a[i]<<" tourists"<<endl;
}
}
for(int i=0; i<=150; i++){
if(y<a[i]){
y=a[i];
m=i;
}
}
cout<<"The countrie with the most visitors is :"<<country[m]<< " with " <<y<< " visitors"<< endl;
}
Reply With Quote