Answer:
<em>The methods is completed as follows</em>
<em>See attachment for .java source file</em>
<em>Comments are used to explain difficult lines</em>
<em>Program starts here</em>
<em></em>
import java.util.*;
public class quiz1
{
public static int doubleOrNothing(int num)
{
if(num<100)
{
num*=2;
}
else{
num = 0;
}
System.out.println(num);
return num;
}
public static String formatPercent(double percent)
{
percent*=100;
System.out.println(percent+"%");
return percent+"%";
}
public static int everyOtherChar(String word)
{
char first = word.charAt(0);
char last = word.charAt(word.length() - 1);
int ascii = (int)first + (int)last;
System.out.print(ascii);
return ascii;
}
public static void main(String [] args)
{
//Testing doubleOrNothing method
int num;
Scanner input = new Scanner(System.in);
System.out.print("Enter any integer number: ");
num = input.nextInt();
System.out.print("Result of doubleOrNothing method\n:");
doubleOrNothing(num);
//Testing formatPercent method
double percent;
System.out.print("Enter any number between 0 and 1: ");
percent = input.nextDouble();
System.out.print("Result of formatPercent method\n:");
formatPercent(percent);
//Testing everyOtherChar method
String word;
System.out.print("Enter any string: ");
word = input.next();
System.out.print("Result of everyOtherChar method\n:");
everyOtherChar(word);
}
}
//See Attached file