الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

اريد المساعده منكم ضروري

مغلق
بدأه طالب سي+ في 5 يناير 2007 · 6 رد · 941 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Write a program that prompts the user to enter the number of required lines to draw an incrementing series of stars. The user should stop if 0 is entered.

Notice the stars are drawn after an indent of aproximately 2 taps.

+++++++++++++++++++++++++++++++

A parking garage charges a $2.00 minimum fee to park for up to three hours.

The garage charges an additional $0.50 per hour for each hour or part of hour in excess of three hours. The maximum charge for any given 24 hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write a program that calculates and prints the parking charges for each of three customers who parked their cars in this garage yesterday.

You should enter the number of hours parked for each customer. Your program should print the results in a neat tabular format and should calculate and print the total of yesterday's receipts. The program should use a function calculateCharges to determine the charge for each customer.

Your output should appear in the following format:

Enter the hours parked for three cars: 1.5 4.0 24.0

Car Hours Charge

1 1.5 2.00

2 4.0 2.50

3 24.0 10.00

TOTAL 29.5 14.50

Press any key to continue

++++++++++++++++++++++++++++

Hints:

• Use a for loop to prompt the user for the number of hours parked for each of the three customers.

• Declare variables to store the total number of hours and the total charges for each customer.

• The variables for all charges and numbers of hours should be of type double.

Function calculateCharges should use a nested if/else structure to determine the customer charge.

هذه السؤالين حاولات احلها بس ماعرفت

اريد اجوبتها الله يعافيكم ضروري

تم تعديل هذه المشاركة بواسطة طالب سي+ في 5 يناير 2007 في 05:31

#2

كيف حاولت,

ضع محاولاتك

ENG. IMAD, Programing is a way of life, It's in the air, we breath It's pumps through our veines, Without it, we soon crumble to dust

#3

#include<iostream>

using namespace std;

int main()

{

int i;

for(i=0;i<=n;i++)

cout<<"Enter number of lines (press 0 to quit):"<<endl;

if(n==0)

cout<<"\n";

cout<<"Good_Bye\n";

return 0;

}

#4

السلام عليكم

البرنامج الذى تعرضة ينقصة اشياء اساسية. مثلاً فى السطر الخاص بادخال رقم. فين اقواس if.

على اى حال البرنامج الموضح سليم لكن لا يطبع. حاول وبالتوفيق

#include<iostream>

using namespace std;
int main()
{
	int i,n;
	do{
		cout<<"Enter number of lines (press 0 to quit):"<<endl;
		cin >>n;
		if(n==0){
			cout<<"\n";
			cout<<"Good_Bye\n";
			break;
		}
		for(i=0;i<=n;i++){

		}

	}while(n!=0);

	return 0;
}
#5

اخي انت كتبت بس الاشياء البسيطه, و تركت فكرة البرنامج خاليه

على اي حال,

#include<iostream>
using namespace std;
int main()
{
	int i,n;
	while(1){
		cout<<"Enter number of lines (press 0 to quit):"<<endl;
		cin >>n;
		if(n==0){
			cout<<"\n";
			cout<<"Good_Bye\n";
			break;
		}
		for(i=0;i<=n;i++){
			for(int j=0;j<i;j++)
				cout<<"*";
			cout<<endl;
		}

	}

	return 0;
}

ضع محاولاتك للاسئله الخرى

تم تعديل هذه المشاركة بواسطة Super_emad55 في 7 يناير 2007 في 00:12

ENG. IMAD, Programing is a way of life, It's in the air, we breath It's pumps through our veines, Without it, we soon crumble to dust

#6

شكرا على المساعده

والسؤال الاول خلاص عرفت احلها

بس عندي اسئله اخرى وإن شاء الله سوف انزلها

#7
#include <iostream>
#include <iomanip>
 #include <cmath>

  double calculateCharges( double );

   main()
  {
  double hour, currentCharge, totalCharges = 0.0, totalHours = 0.0;
  int first = 1;

  cout << "Enter the hours parked for 3 cars: ";

  for ( int i = 1; i <= 3; i++ ) {
  cin >> hour;
  totalHours += hour;
  if ( first ) {
  cout << setw( 5 ) << "Car" << setw( 15 ) << "Hours"
  << setw( 15 ) << "Charge\n";
  first = 0; // prevents this from printing again
  }

  totalCharges += ( currentCharge = calculateCharges( hour ) );
  cout << setiosflags( ios::fixed | ios::showpoint )
  << setw( 3 ) << i << setw( 17 ) << setprecision( 1 ) << hour
  << setw( 15 ) << setprecision( 2 ) << currentCharge << "\n";
  }

  cout << setw( 7 ) << "TOTAL" << setw( 13 ) << setprecision( 1 )
  << totalHours << setw( 15 ) << setprecision( 2 )
  << totalCharges << endl;


  return 0;
  }

 double calculateCharges( double hours )
  {
 double charge;

  if ( hours < 3.0 )
  charge = 2.0;
  else if ( hours < 19.0 )
  charge = 2.0 + .5 * ceil( hours - 3.0 );
  else
  charge = 10.0;

  return charge;
}

هذا الموضوع مغلق.

مواضيع مشابهة