Uploaded by ivanmusuba7

Method Assignment PART 1

advertisement
// METHOD ASSIGNMENT - 7 OCT 2022
//In this assignment I will be creating methods
// WRITE A METHOD NAMED TRANSLATE THAT TAKES AN INTEGER PARAMETER AND
RETURNS A DOUBLE
public class Main
{
public static void main(String[] args) {
int y= 10;
System.out.println(translate(y));
}
public static double translate(int a) {
return(a*1);
}
}
// Write a method named FIND that takes a String and a int as parameters and returns a
boolean.
public class Main
{
public static void main(String[] args) {
String y = "Does string y have characters equal to int z: ";
int z = 46;
System.out.print(y +find(y,z));
}
public static boolean find(String y,int a){
int l = y.length();
if(a==l) return true;
else return false;
}
}
// Write a method named printAnswer that thakes three doubles as parameters and does not
return anything but outputs their product
public class Main
{
public static void main(String[] args) {
double y = 1.2;
double a = 3.4;
double z= 3.0;
printAnswer(y,a,z);
}
public static void printAnswer(double y , double a , double z){
double sum = y*a*z;
System.out.println("The product of three doubles is :" +sum);
}
Download