هذا البرنامج مطلوب مني اني اسلمه بكره , و عندي مشكلة ميش عارف ايه هي , احتاج لمن يستطيع مساعدتي ضروري
البرنامج المطلوب في المرفقات , و ما توصلت إليه ايضآ في المرفقات
احتاج المساعدة في اسرع وقت ممكن
هناك تعديل يسيط ويعمل البرنامج راجعة
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int type, vehicles_class;
double registration_fee = 0, total_registration_fee = 0, surcharge = 0, additional_surcharge = 0;
cout << "The DMV classifies automobiles as (type 1) for Luxury,or (type 2) for all others" << endl;
cout << "For Luxury ,Please enter 1 ,or for others ,Please enter 2 :";
cin >> type;
cout << endl;
if (type = 1)
{
registration_fee = 35;
surcharge = 15;
total_registration_fee = registration_fee + surcharge;
cout << "The DMV also classifies automobiles as City vehicle (class 1) , or non-city vehicle (class 2). \n" << endl;
cout << "An automobile that is registered in the city of Metropolis , must pay an additional surcharge of $20 .\n" << endl;
cout << "For City vehicle ,Please enter 1 ,or for non-city vehicle ,Please enter 2 :";
cin >> vehicles_class;
cout << endl;
if (vehicles_class = 1)
{
registration_fee = 35;
additional_surcharge = 20;
total_registration_fee = registration_fee + additional_surcharge;
}
else if (vehicles_class = 2);
{
registration_fee = 35;
total_registration_fee += registration_fee;
}
}
else (type = 2);
{
registration_fee = 35;
total_registration_fee += registration_fee;
}
cout << "Total registration fees=" << " $ " << total_registration_fee << endl;
system("pause");
return 0;
}والله ولى التوفيق
اخي الكريم محمد شكرآ لك علي مرورك
ولكني قد حاولات كثيرآ ولكني لم اصل لشئ , اعرف انها مشكلة if و else if ولكني لا اعرف حلها
فالو تكرمت اخي كتابة البرنامج مصحح و تفسر لي خطئ
لست متأكده من الحل كثيرا ,و لكن جرب هذا ..:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int type, vehicles_class;
double registration_fee = 0, total_registration_fee = 0, surcharge = 0, additional_surcharge = 0;
cout << "The DMV classifies automobiles as (type 1) for Luxury,or (type 2) for all others" << endl;
cout << "For Luxury ,Please enter 1 ,or for others ,Please enter 2 :";
cin >> type;
cout << endl;
if (type == 1)
{
registration_fee = 35;
surcharge = 15;
total_registration_fee = registration_fee + surcharge;
cout << "The DMV also classifies automobiles as City vehicle (class 1) , or non-city vehicle (class 2). \n" << endl;
cout << "An automobile that is registered in the city of Metropolis , must pay an additional surcharge of $20 .\n" << endl;
cout << "For City vehicle ,Please enter 1 ,or for non-city vehicle ,Please enter 2 :";
cin >> vehicles_class;
cout << endl;
if (vehicles_class == 1)
{
registration_fee = 35;
additional_surcharge = 20;
total_registration_fee = registration_fee + additional_surcharge;
}
else if (vehicles_class == 2);
{
registration_fee = 35;
total_registration_fee += registration_fee;
}
}
else (type == 2);
{
registration_fee = 35;
total_registration_fee += registration_fee;
}
cout << "Total registration fees=" << " $ " << total_registration_fee << endl;
system("pause");
return 0;
}البرنامج شغال و لكن في غلط في الحساب
أرجوا حل المشكلة
أنا آسفه لكن لم افهم السؤال المطلوب منك جيدا بحكم اني مبتدئه :\ ..
بالتوفيق ..
ولا يهمك اختي و شكرآ علي مساعدتك
السلام عليكم أتمنى أن يكون هذا ما تريده
#include <iostream>
#include <cstdlib>
using namespace std;
int main(int argc, char * argv[]){
int vehicles_class = 0, city_class = 0;
double registration_fee = 35.0;
char check = 0;
while(true){
cout << "The DMV classifies automobiles as (type 1) for Luxury,or (type 2) for all others" << endl;
cout << "For Luxury ,Please enter 1 ,or for others ,Please enter 2 :" << endl;
cin >> vehicles_class;
cout << "The DMV also classifies automobiles as city vehicles(class 1) or non-city vehicles(class 2)." << endl;
cin >> city_class;
if(vehicles_class == 1){
registration_fee += 15;
if(city_class == 1){
registration_fee += 20;
}
}
else{
if(city_class == 1){
registration_fee += 20;
}
}
cout << "Total registration fees = " << registration_fee << " $ " << endl;
cout << "\n\nif you want calculate another automoblies fee please type any key." << endl;
cout << "\nif you want to exit please type \"q \"." << endl;
cin >> check;
if(check == 'q'){
break;
}
registration_fee = 35;
}
system("pause");
return 0;
}