1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lubasha [3.4K]
3 years ago
14

This was a quiz that I submitted earlier in the semester but I had not received full points due to a coding mistake. Below, I wi

ll provide the instructions and the code that needs to be changed in order for the program to work. Any place that has a "// Student Code Here" or "// Test Your Methods Here" must be changed accordingly.------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------INSTRUCTIONS:Step 1Fill in the doubleOrNothing method, which takes an int as a parameter. If the number is less than 100, return that number doubled. Otherwise, return zero.For example, passing 4 to this method would return 8, but passing 104 to this method would return 0.Step 2Fill in the formatPercentmethod, which takes a double as a parameter that represents a percent value between 0 and 1. This method returns a String that is the percentage between 0 and 100 percent, with one place following the decimal before a '%'.For example, passing the double '.85' would return the string "85.0%".Step 3Fill in the everyOtherChar method, which takes a String parameter called word*. This method returns an int which computes the sum of the ASCII values of *every other* character in the parameter word, starting with the first character.For example, passing the word "yam" into the method would tally the ASCII value of the characters 'y' and 'm', which have ASCII values of 121 and 109 respectively, so the method would return 230.Test Your MethodsTest your methods by calling them within main. You may run your program in Develop mode as many times as you would like, but you may only submit your program once.------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------CODE:public class quiz1 { // Step 1 public static int doubleOrNothing(int num) {e // student code here } // Step 2 public static String formatPercent(double percent) { // student code here } // Step 3 public static int everyOtherChar(String word) { // student code here } public static void main(String [] args) { // test your methods here! }}
Computers and Technology
1 answer:
Naddik [55]3 years ago
5 0

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

Download java
You might be interested in
What are the qualitative data items about text book​
Wittaler [7]

Answer:

Qualitative data is defined as the data that approximates and characterizes. Qualitative data can be observed and recorded. ... This type of data is collected through methods of observations, one-to-one interviews, conducting focus groups, and similar methods.

8 0
3 years ago
The Event Viewer (Microsoft Windows) or Console (Apple Mac OS X) is used for what purpose?
Sveta_85 [38]

Answer:

to view incidents recorded in the Application, Security, and System logs

Explanation:

8 0
3 years ago
Have all of my coins because i will delete acount there will be part 2, 3 , 4 ,5,6,7,8
kirza4 [7]
Thank you very much your are awesome
3 0
3 years ago
Read 2 more answers
Question 7 of 10
SpyIntel [72]

Answer:

A

Explanation:

6 0
2 years ago
Use the pulley image below to help u answer. click on it if u cant see.
Crank
1 is 2 2 is 0 because the pull of the box is removed
8 0
3 years ago
Read 2 more answers
Other questions:
  • What is not critical when you are first designing a database?
    9·1 answer
  • What is the default file extension for a document created in Word 2016?​
    14·1 answer
  • Explain why the scenario below fails to meet the definition an assembly line.
    10·1 answer
  • There are two different perspectives in terms of how programs are delivered for different ethnic groups. If an agency offers dif
    14·1 answer
  • You are going to write a program for Computer test which will read 10 multiple choice questions from a file, order them randomly
    11·1 answer
  • Contrast the performance of the three techniques for allocating disk blocks (contiguous, linked, and indexed) for both sequentia
    13·1 answer
  • Select the device that will have the most network ports
    8·1 answer
  • Many companies ban or restrict the use of flash drives
    11·1 answer
  • Which function in Ecels tells how many numeric entries are there​
    7·2 answers
  • How do IT Support professionals measure success? Choose all answers that apply. You will get credit for all answers that are cor
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!