Προς το περιεχόμενο

ασκηση σε php


pioneer2

Προτεινόμενες αναρτήσεις

Δημοσ.

Έχω αυτή την άσκηση

 

 

Αdd a function to the PHP scipt below which takes two parameters: (1) the number of years and (2) the amount of money to be put on a savings account. The function should calculate the amount that will have been reached after the given number of years. To print an amount with no more than two decimals, us the sprintf function, for instance, as follows: sprintf("%.2f", $amount ) ;

 

/*

Add function here

*/

 

print "<p><b>The current interest rate is 5%.</b></p>" ;

 

print " <p>When you deposit € 50 today, your savings accounts will have grown to €" ;

print calculateAmount(10 , 50) ;

print " in 10 years.</p>"

 

 

print " <p>When you deposit € 1,500 today, your savings will have grown to €" ;

print calculateAmount(20 , 1500) ;

print " after 5 years.</p>" ;

 

όποιος μπορεί ας βοηθήσει!!

ευχαριστώ

Δημοσ.

για να βρεις πόσα κερδίζεις κάνεις

κέρδος = κεφάλαιο * επιτόκιο * χρόνια

 

*Στο δεύτερο έχεις βάλει 20 στο όρισμα της calculateAmount ενώ το θες για 5χρόνια.

Δημοσ.

Έχω αυτή την άσκηση

 

 

Αdd a function to the PHP scipt below which takes two parameters: (1) the number of years and (2) the amount of money to be put on a savings account. The function should calculate the amount that will have been reached after the given number of years. To print an amount with no more than two decimals, us the sprintf function, for instance, as follows: sprintf("%.2f", $amount ) ;

 

/*

Add function here

*/

 

print "<p><b>The current interest rate is 5%.</b></p>" ;

 

print " <p>When you deposit € 50 today, your savings accounts will have grown to €" ;

print calculateAmount(10 , 50) ;

print " in 10 years.</p>"

 

 

print " <p>When you deposit € 1,500 today, your savings will have grown to €" ;

print calculateAmount(5 , 1500) ;

print " after 5 years.</p>" ;

 

όποιος μπορεί ας βοηθήσει!!

ευχαριστώ

Έλα ρε συ αυτή είναι πανεύκολη. Μάλλον δε παρακολουθούσες το μάθημα :P

>function calculateAmount( $years, $money )
{
  return $money * ($money * 0.05) * $years;
}
print "<p><b>The current interest rate is 5%.</b></p>" ;
sprintf("<p>When you deposit € 50 today, your savings accounts will have grown to € %.2f in 10 years.</p>", calculateAmount( 10 , 50 ) )

sprintf("<p>When you deposit € 1,500 today, your savings will have grown to € %.2f after 5 years.</p>", calculateAmount(5 , 1500) )

Δημοσ.

Έλα ρε συ αυτή είναι πανεύκολη. Μάλλον δε παρακολουθούσες το μάθημα :P

>function calculateAmount( $years, $money )
{
  return $money * ($money * 0.05) * $years;
}
print "<p><b>The current interest rate is 5%.</b></p>" ;
sprintf("<p>When you deposit € 50 today, your savings accounts will have grown to € %.2f in 10 years.</p>", calculateAmount( 10 , 50 ) )

sprintf("<p>When you deposit € 1,500 today, your savings will have grown to € %.2f after 5 years.</p>", calculateAmount(5 , 1500) )

 

Eυχαριστώ πάρα πολύ φίλε μου, να είσαι πάντα καλά.

Δημοσ.

pioneer2 όσον αφορά τον τύπο δεν είμαι σίγουρος για το πως προστίθεται το επιτόκιο.

Δε θυμάμαι αν το επιτόκιο αυξάνεται με βάση του αρχικού λογαριασμού ή αν αυξάνεται τον πρώτο χρόνο με βάση τα 1500 ευρώ και μετά κάθε χρόνο αν προστίθεται 5% στο ήδη αυξημένο ποσό κατά 5%, δηλαδή ισχύει (1500 + 5%) + 5% για 2 χρόνια, ((1500 + 5%) + 5% ) + 5% για 3 κ.ο.κ.. Αν τυχόν ισχύει αυτό τότε είναι σωστός ο κώδικας που σου έδωσα. Αν δεν είναι σωστό αυτό, τότε ισχύει:

 

>
return $money + ($money * 0.05 ) * years

Δηλαδή το επιτόκιο είναι 5% ή 0.05 που το πολλαπλασιάζεις με το κεφάλαιο για να βρεις πόσο αυξάνεται με το χρόνο. $money * 0.05 ισούται με 75, δηλαδή το χρόνο κερδίζεις 75ευρώ στα 1500ευρώ στα 10 χρόνια το κεφάλαιό σου θα γίνει 1500+750=2250

Αν μπορεί ας απαντήσει κάποιος που ξέρει περισσότερα οικονομικά... :unsure:

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...