soru :
Question 1: Print the following table to display the sin value and cos value of degrees from 0
to 360 with increments of 10 degrees.
Degree Sin Cos
0 0.0 1.0
10 0.1736 0.9848
.
.
.
360 0.0 1.0

cevap:

System.out.println("Degree Sin Cos");

for (int degree = 0; degree <= 360; degree += 10)

double radians = Math.toRadians(degree);
double sin = Math.sin(radians);
double cos = Math.cos(radians);
System.out.printf("%d%5.4f%5.4f\n", degree, sin, cos);

 

for'un küme parantezleri var mı normalde? yoksa sadece burada mı yok? sorun o olabilir.

lemmiwinks

for'un altındakileri kıvrık paranteze almamışsın.

Çözüm bu değilse, yaşadığın problemi (compile hatası, yanlış sonuç vs) yaz ki daha iyi yardımcı olalım.

long live rock n roll

public class Trig {
public static void main(String[] args) {
System.out.println("Degree Sin Cos");

for (int degree = 0; degree <= 360; degree += 10)

double radians = Math.toRadians(degree);
double sin = Math.sin(radians);
double cos = Math.cos(radians);
System.out.printf("%d%5.4f%5.4f\n", degree, sin, cos);
}
}

tam olarak bu. sıkıntı var ama..

kurkcudukkaninadonentilki

eyv dediginiz gibi ty:D bi de su soru var. bunu hem anlamadım. hem de giris yapamadım. baslangıc verin gerisi benden :D

soru :
Question 2: Write two seperate methods with the same name but different parameter list
that display n by n and m by n matrix. The elements of the matrix are the numbers between
1 and 10.

kurkcudukkaninadonentilki

void DisplayMatrix (int n)
{
for (int i=0; i<n; i++)
for (int j=0; j<n; j++)
// burada bir takim sayilar yazacaksin. 1'den 10'a diye ne demek istemis bilemedim
}

void DisplayMatrix (int n, int m)
{
for (int i=0; i<n; i++)
for (int j=0; j<m; j++)
// burada bir takim sayilar yazacaksin. 1'den 10'a diye ne demek istemis bilemedim
}

long live rock n roll

yanlış anlamadıysam n'e n'lik matris için tek bir sayı alan, m'e n'lik matris için de 2 sayı alan aynı isimli iki metot yazılması istenmiş. sanırım matrisin elemanları 1 ile 10 arasında rastgele sayılar olacak. aynı isimli iki metot olduğunda parametrelere göre çalıştırılacak olan metotu seçiyor ya java, onu görmek için işte.

lemmiwinks
1

mobil görünümden çık