I need help please We are using jGRASP software. I will really...
Please make sure to Debug on this assignment
I will really appreciate. Have a great day!
I only need help with 2 files DigitPlay.java and TeddyBear.java
That's all the Information I have got
Power.java is given
import java.util.Scanner;
public class Power {
public static void main(String[] args) {
int base, exp;
int answer;
Scanner scan = new Scanner(System.in);
System.out.print("Welcome to the power program! ");
System.out.println("Please use integers only.");
//get base
System.out.print("Enter the base you would like raised to a power: ");
base = scan.nextInt();
//get exponent
System.out.print("Enter the power you would like it raised to: ");
exp = scan.nextInt();
answer = power(base,exp);
System.out.println(base + " raised to the " + exp + " is " + answer);
}
/*
Method: Computes and returns base^exp
Param: int base, int exp
Return: int
*/
public static int power(int base, int exp) {
int pow;
if(exp ==0) {
return 1;
} else {
return base * power(base, exp-1);
}
}
}
Backwards.java is given
import java.util.Scanner;
public class Backwards {
public static void main(String[] args) {
String msg;
Scanner scan = new Scanner(System.in);
// Accept a string from user
System.out.print("Enter a string: ");
msg = scan.nextLine();
System.out.print("\nThe string backwards: ");
printBackwards(msg); // method call
System.out.println();
}
/*
Method: Takes a string and recursively prints it backwards
Param: String
Return: void
*/
public static void printBackwards (String s) {
if ((s==null)||(s.length() <= 1))
{
System.out.println(s);
}
else
{
System.out.print(s.charAt(s.length()-1));
printBackwards(s.substring(0,s.length()-1));
}
}
}
sectetur adipiscing elit. Nam lacinia pulvinar tortor ne
sectetur adipi
sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui
secteturUnlock access to this and over
10,000 step-by-step explanations
Have an account? Log In
sectetur adipisci
sect
sect
sect
secte
secte