kellytang 3 anni fa
parent
commit
d58fa95475
2 ha cambiato i file con 30 aggiunte e 4 eliminazioni
  1. +3
    -4
      tutorial/CalSumOfGeo.java
  2. +27
    -0
      tutorial/CalVolOfCylinder.java

+ 3
- 4
tutorial/CalSumOfGeo.java Vedi File

@@ -8,10 +8,9 @@ import java.util.Scanner;
public class CalSumOfGeo {
public static void main(String[] args){
double a, R, n;
double sumOfGeo;
Scanner input = new Scanner(System.in);
double sumofGS;
System.out.print("Enter the first number of the sequence: ");
a = input.nextDouble();
@@ -21,10 +20,10 @@ public class CalSumOfGeo {
System.out.print("Enter the number of the terms of the sequence: ");
n = input.nextDouble();
sumofGS = (a*(Math.pow(R,n)-1))/(R-1);
sumOfGeo = (a*(Math.pow(R,n)-1))/(R-1);
System.out.print("The sum of Geometric Series: ");
System.out.printf("%1.1f\n" , sumofGS);
System.out.printf("%1.1f\n" , sumOfGeo);
}
}

+ 27
- 0
tutorial/CalVolOfCylinder.java Vedi File

@@ -0,0 +1,27 @@
package tutorial;

import java.util.Scanner;

public class CalVolOfCylinder {
public static void main (String [] args)
{
String strRadius , strLength;
double radius , length, volume;
Scanner input = new Scanner(System.in);

System.out.print("Enter the radius: ");
strRadius = input.nextLine();

System.out.print("Enter the length: ");
strLength = input.nextLine();
radius = Double.parseDouble(strRadius);
length = Double.parseDouble(strLength);
volume = Math.pow(radius,2) * Math.PI * length;
System.out.println("The volume of the cylinder with radius= " + radius + " and length= " + length + " is " + volume + ".");
}
}

Caricamento…
Annulla
Salva