Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write the algorathim then Java program the declares an integer variable and a

ID: 3621164 • Letter: 1

Question

1. Write the algorathim then Java program the declares an integer variable and assign it afour - digit positive integer numbe the progrsm thn out the digits of the number one digit per line For example, if the number is 3245 the output is
3
2
4
5
2. design n algorithm then implemnt a java program that defines and initializes two integer a= 18 and b= 4 then computes and diplay the followings
the quotient of dividing a by b
the remainder of dividing a by b
the result in floating point of dividing a by b
3 computing the volume of cylinder write agorthimand java program that reads in the radius and(radius = 5)and the length of cylinderand computes its volum using the following formulas
area= radius *radius p
volume = aerea* length














Explanation / Answer

1.

public static void main(String[] args)
{
int num = 3245;

printDigits(num);
}

public static void printDigits(int num)
{
String temp = ""+num;

for(char c : temp.toCharArray())
{
System.out.println(c);
}
}

2.

public static void main(String[] args)
{
int a = 18;
int b = 4;

int quotient = a/b;
int remainder = a%b;
int floatingPointDiv = (double)a/b;

System.out.println(quotient);
System.out.println(remainder);
System.out.println(floatingPointDiv);
}

3.

import java.util.Scanner;

public class CylinderVolume
{
public static void main(String[] args)
{
// input
Scanner kb = new Scanner(System.in);

System.out.print("Enter the radius: ");
double radius = kb.nextDouble();

System.out.print("Enter the length: ");
double length = kb.nextDouble();

// calculations
double area = radius*radius*Math.PI;
double volume = area*length;

System.out.println("Area = "+area);
System.out.println("Volume = "+volume);


}
}