tekrar merhaba,
ben amacımı söyliyeyim siz ona göre yardım edin :)
fortran da öyle bir program yazmak istiyorum ki:
-program önce laptopun alındığı ülkeyi veya ülkenin para birimini, sonra laptopun tutarını sorsun.
-akabinde girilen verilere göre ülkenin parasını tl ye çevirsin.
-en sonda da belirlediğimiz aralıklara göre laptopun pahalı ya da ucuz olduğunu söylesin.
---tüm bunlar için yazdığım programın kodu:---
program hmwrk2
character (len=11)::dollar, yen, tl, sterlin, england, usa, germany, turkey, japan, unit, euro
real::p, t
print*, "please enter the name of country or Money Unit in which laptop is sold"
read*, unit
if (unit==dollar .or. unit==usa) then
print*, "please enter the price of the laptop computer"
read*, price
t = p * 1.46
else if (unit==euro .or. unit==germany) then
print*, "please enter the price of the laptop computer"
read*, p
t = p * 1.48
else if (unit==yen .or. unit==japan) then
print*, "please enter the price of the laptop computer"
read*, p
t = price * 0.02
else
end if
if (t<1750) then
print*,"laptop computer is",t,"TL","and it is very cheap!"
else if (t<2000 .and. t>1750) then
print*, "laptop computer is",t,"TL","and it is cheap!"
else if (t<2200 .and. t>2000) then
print*,"laptop computer is",t,"TL","and it is expensive!"
else if then
print*,"laptop computer is",t,"TL","and it is very expensive!"
else
end if
end program hmwrk2
şimdiden teşekkürler.
ben amacımı söyliyeyim siz ona göre yardım edin :)
fortran da öyle bir program yazmak istiyorum ki:
-program önce laptopun alındığı ülkeyi veya ülkenin para birimini, sonra laptopun tutarını sorsun.
-akabinde girilen verilere göre ülkenin parasını tl ye çevirsin.
-en sonda da belirlediğimiz aralıklara göre laptopun pahalı ya da ucuz olduğunu söylesin.
---tüm bunlar için yazdığım programın kodu:---
program hmwrk2
character (len=11)::dollar, yen, tl, sterlin, england, usa, germany, turkey, japan, unit, euro
real::p, t
print*, "please enter the name of country or Money Unit in which laptop is sold"
read*, unit
if (unit==dollar .or. unit==usa) then
print*, "please enter the price of the laptop computer"
read*, price
t = p * 1.46
else if (unit==euro .or. unit==germany) then
print*, "please enter the price of the laptop computer"
read*, p
t = p * 1.48
else if (unit==yen .or. unit==japan) then
print*, "please enter the price of the laptop computer"
read*, p
t = price * 0.02
else
end if
if (t<1750) then
print*,"laptop computer is",t,"TL","and it is very cheap!"
else if (t<2000 .and. t>1750) then
print*, "laptop computer is",t,"TL","and it is cheap!"
else if (t<2200 .and. t>2000) then
print*,"laptop computer is",t,"TL","and it is expensive!"
else if then
print*,"laptop computer is",t,"TL","and it is very expensive!"
else
end if
end program hmwrk2
şimdiden teşekkürler.

programın derleme aşamasında mı hata verdi? yoksa derlendi ama düzgün çalışmadı mı? sorunun ne olduğunu yazmalısın.
bir de; if ifadelerinde en sonda else kısmında bir şey yazmıyorsun o yüzden o bölgeyi kaldır.
quanta


program çalıştı, bana "unit" değerini sordu girdiğimde de şu hatayı verdi:
i42.tinypic.com
ferishtah


usa,dollar,euro,germany,yen ve japan 'ı değişken olarak tanımlamışsın ama bunlar sadece karakter. if ifadesinin içinde " işareti arasına alınmalı "usa" gibi. programın başındaki tanımlamalarını da silersen sorun ortadan kalkacaktır.
quanta


çok teşekkürler. bir de p yerine price girmişim. düzeltince sorunsuz çalıştı.
ferishtah

1