PROGRAM 8: Grade Converter! For this program, I would like you to create a function which returns a character value based on a floating point value as

Answers

Answer 1

Answer:

This function will return a character grade for every floating-point grade for every student in the class.

function grade( floatPoint ){

      let text;

      switch ( floatPoint ) {

        case floatPoint < 40.0 :

             text= " F ";

             break;

        case floatPoint == 40.0 :

             text= " P ";

             break;

        case floatPoint > 40.0 && floatPoint <= 50.0 :

             text=  " C ";

             break;

        case floatPoint > 50.0 && floatPoint < 70.0 :

             text=  " B ";

             break;

        case floatPoint >=70.0 && floatPoint <= 100.0 :

             text= " C ";

             break;

        default :

            text= "Floating point must be between 0.0 to 100.0"

      }

     return text;

}

Explanation:

This javascript function would return a character grade for floating-point numbers within the range of 0.0 to 100.0.


Related Questions

Write a method named coinFlip that accepts as its parameter a string holding a file name, opens that file and reads its contents as a sequence of whitespace-separated tokens. Assume that the input file data represents results of sets of coin flips. A coin flip is either the letter H or T, or the word Heads or Tails, in either upper or lower case, separated by at least one space. You should read the sequence of coin flips and output to the console the number of heads and the percentage of heads in that line, rounded to the nearest whole number. If this percentage is 50% or greater, you should print a "You win!" message; otherwise, print "You lose!". For example, consider the following input file: H T H H T Tails taIlS tAILs TailS heads HEAds hEadS For the input above, your method should produce the following output: 6 heads (50%) You win!

Answers

Answer:

Here is the JAVA program:

import java.io.*;

import java.util.*;

public class Main {

public static void main(String[] args) throws FileNotFoundException{ //the start of main() function body, it throws an exception that indicates a failed  attempt to open the file

Scanner input = new Scanner(new File("file.txt")); //creates a Scanner object and a File object to open and scan through the file.txt    

coinFlip(input);    } //calls coinFlip method

public static void coinFlip(Scanner input) { //coinFlip method that accepts as its parameter a string input holding a file name

while(input.hasNextLine()) { //iterates through the input file checking if there is another line in the input file

Scanner scan = new Scanner(input.nextLine()); //creates a Scanner object

int head = 0; // stores count of number of heads

int count = 0; //stores count of  total number of tokens

while(scan.hasNext()) { //iterates through the sequence checking if there is another sequence in the input file

String token= scan.next(); // checks and returns the next token

if (token.equalsIgnoreCase("H")||token.equalsIgnoreCase("Heads")) { //compares H or Heads with the tokens in file ignoring lower case and upper case differences

           head++;                } //if a token i.e. any form of heads in file matches with the H or Heads then add 1 to the number of heads

           count++;            } //increment to 1 to compute total number of counts

double result = Percentage(head, count); //calls Percentage method passing number of heads and total counts to compute the percentage of heads

System.out.println(head + " heads " + "(" + result +"%)"); // prints the number of heads

if(result >= 50.00) { //if the percentage is greater or equal to 50

System.out.println("You win!");} //displays this message if above if condition is true

else //if the percentage is less than 50

{System.out.println("You lose!");}  }    } //displays this message if above if condition is false

public static double Percentage(int h, int total) { //method to compute the percentage of heads

double p = (double)h/total* 100; // divide number of heads with the total count and multiply the result by 100 to compute percentage

return p;    } } //returns result

Explanation:

The program is well explained in the comments mentioned with each line of the above code. I will explain how the method coinFlip  works.

Method coinFlip accepts a string holding a file name as its parameter. It opens that file and reads its contents as a sequence of tokens. Then it reads and scans through each token and the if condition statement:

if (token.equalsIgnoreCase("H")||token.equalsIgnoreCase("Heads"))

checks if the each token in the sequence stored in the file is equal to the H or Heads regardless of the case of the token. For example if the first token in the sequence is H then this if condition evaluates to true. Then the head++ statement increments the count of head by 1. After scanning each token in the sequence the variable count is also increased to 1.

If the token of the sequence is HeAds then this if condition evaluates to true because the lower or upper case difference is ignored due to equalsIgnoreCase method. Each time a head is found in the sequence the variable head is incremented to 1.

However if the token in the sequence is Tails then this if condition evaluates to false. Then the value of head variable is not incremented to 1. Next the count variable is incremented to 1 because this variable value is always incremented to 1 each time a token is scanned because count returns the total number of tokens and head returns total number of heads in the tokens.

Percentage method is used to return the percentage of the number of heads in the sequence. It takes head and count as parameters (h and total). Computes the percentage by this formula h/total* 100. If the result of this is greater than or equal to 50 then the message  You win is displayed otherwise message You lose! is displayed in output.

Consider the following calling sequences and assuming that dynamic scoping is used, what variables are visible during execution of the last function called? Include with each visible variable the name of the function in which it was defined.a. Main calls fun1; fun1 calls fun2; fun2 calls fun3b. Main calls fun1; fun1 calls fun3c. Main calls fun2; fun2 calls fun3; fun3 calls fun1d. Main calls fun3; fun3 calls fun1e. Main calls fun1; fun1 calls fun3; fun3 calls fun2f. Main calls fun3; fun3 calls fun2; fun2 calls fun1void fun1(void);void fun2(void);void fun3(void);void main() {Int a,b,c;…}void fun1(void){Int b,c,d;…}void fun2(void){Int c,d,e;…}void fun3(void){Int d,e,f;…}

Answers

Answer:

In dynamic scoping the current block is searched by the compiler and then all calling functions consecutively e.g. if a function a() calls a separately defined function b() then b() does have access to the local variables of a(). The visible variables with the name of the function in which it was defined are given below.

Explanation:

In main() function three integer type variables are declared: a,b,c

In fun1() three int type variables are declared/defined: b,c,d

In fun2() three int type variables are declared/defined: c,d,e

In fun3() three int type variables are declared/defined: d,e,f

a. Main calls fun1; fun1 calls fun2; fun2 calls fun3

Here the main() calls fun1() which calls fun2() and fun2() calls func3() . This means first the func3() executes, then fun2(), then fun1() and last main()

Visible Variable:  d, e, f        Defined in: fun3

Visible Variable: c                 Defined in: fun2 (the variables d and e of fun2  

                                                                                                     are not visible)

Visible Variable: b                  Defined in: fun1 ( c and d of func1 are hidden)

Visible Variable: a                 Defined in: main (b,c are hidden)

b. Main calls fun1; fun1 calls fun3

Here the main() calls fun1, fun1 calls fun3. This means the body of fun3 executes first, then of fun1 and then in last, of main()

Visible Variable: d, e, f           Defined in: fun3

Visible Variable:  b, c              Defined in: fun1 (d not visible)

Visible Variable:  a                  Defined in: main ( b and c not visible)

c. Main calls fun2; fun2 calls fun3; fun3 calls fun1

Here the main() calls fun2, fun2 calls fun3 and fun3 calls fun1. This means the body of fun1 executes first, then of fun3, then fun2 and in last, of main()

Visible Variable:  b, c, d        Defined in: fun1

Visible Variable:  e, f             Defined in: fun3 ( d not visible)

Visible Variable:  a                Defined in: main ( b and c not visible)

Here variables c, d and e of fun2 are not visible

d. Main calls fun3; fun3 calls fun1

Here the main() calls fun3, fun3 calls fun1. This means the body of fun1 executes first, then of fun3 and then in last, of main()

Visible Variable: b, c, d     Defined in: fun1  

Visible Variable:   e, f        Defined in:  fun3   ( d not visible )

Visible Variable:    a          Defined in: main (b and c not visible)

e. Main calls fun1; fun1 calls fun3; fun3 calls fun2

Here the main() calls fun1, fun1 calls fun3 and fun3 calls fun2. This means the body of fun2 executes first, then of fun3, then of fun1 and then in last, of main()

Visible Variable: c, d, e        Defined in: fun2

Visible Variable:  f               Defined in: fun3 ( d and e not visible)

Visible Variable:  b               Defined in:  fun1 ( c and d not visible)

Visible Variable: a                Defined in: main ( b and c not visible)

f. Main calls fun3; fun3 calls fun2; fun2 calls fun1

Here the main() calls fun3, fun3 calls fun2 and fun2 calls fun1. This means the body of fun1 executes first, then of fun2, then of fun3 and then in last, of main()

Visible Variable: b, c, d       Defined in: fun1  

Visible Variable: e               Defined in: fun2  

Visible Variable: f                Defined in: fun3  

Visible Variable: a               Defined in: main

The fact that the speed of a vehicle is lower than the prescribed limits shall relieve the driver from the duty to decrease speed when approaching and crossing an intersection. True or false

Answers

Explanation:

the answer is false ........

The fact that the speed of a vehicle is lower than the prescribed limits shall relieve the driver from the duty to decrease speed when approaching and crossing an intersection is not true.

What is intersection in the traffic rules?

An intersection serves as the point where many lanes cross on the road which is a point where driver is required to follow the traffic rules.

However, the above statement is not true because , a driver can decide not  decrease speed when approaching and crossing an intersection, even though it is a punishable offense in traffic rules.

Read more on traffic rules here: https://brainly.com/question/1071840

#SPJ2

What is the quick key to highlighting a column?
Ctrl + down arrow
Ctrl + Shift + down arrow
Right-click + down arrow
Ctrl + Windows + down arrow

Answers

The quick key to highlighting a column is the Ctrl + Shift + down arrow. Thus, option (b) is correct.

What is column?

The term column refers to how data is organized vertically from top to bottom. Columns are groups of cells that are arranged vertically and run from top to bottom. A column is a group of cells in a table that are vertically aligned. The column is the used in the excel worksheet.

The quick key for highlighting a column is Ctrl + Shift + down arrow. To select downward, press Ctrl-Shift-Down Arrow. To pick anything, use Ctrl-Shift-Right Arrow, then Ctrl-Shift-Down Arrow. In the Move/Highlight Cells, the was employed. The majority of the time, the excel worksheet was used.

As a result, the quick key to highlighting a column is the Ctrl + Shift + down arrow. Therefore, option (b) is correct.

Learn more about the column, here:

https://brainly.com/question/3642260

#SPJ6

Answer:

its (B) ctrl+shift+down arrow

hope this helps <3

Explanation:

A machine on a 10 Mbps network is regulated by a token bucket algorithm with a fill rate of 3 Mbps. The bucket is initially filled to capacity at 3MB. How long can the machine transmit at the full 10 Mbps capacity

Answers

2+4= this gbhfchgcjdxbhdch is correct

Write a program that reads the input.txt file character by character and writes the content of the input file to output.txt with capitalize each word (it means upper case the first letter of a word and lowercase remaining letters of the word)

Answers

Answer:

def case_convertfile( file_name):

    with open(" new_file","x") as file:

         file.close( )

    with open("file_name", "r") as txt_file:

     while True:

            word = txt_file.readline( )

            word_split= word.split(" ")

            for word in word_split:

                  upper_case = word.uppercase( )

                  file= open("new_file","w+")

                  file= open("new_file","a+")

                  file.write(upper_case)

     txt_file.close( )

     file.close( )

Explanation:

This python function would open an existing file with read privilege and a new file with write and append privileges read and capitalize the content of the old file and store it in the new file.

Cloud computing gives you the ability to expand and reduce resources according to your specific service requirement.

a. True
b. False

Answers

Answer:

a. True

Explanation:

Cloud computing can be defined as a type of computing that requires shared computing resources such as cloud storage (data storage), servers, computer power, and software over the internet rather than local servers and hard drives.

Generally, cloud computing offers individuals and businesses a fast, effective and efficient way of providing services.

In Computer science, one of the most essential characteristics or advantages of cloud computing is rapid elasticity.

By rapid elasticity, it simply means that cloud computing gives you the ability to expand and reduce resources according to your specific service requirement because resources such as servers can be used to execute a particular task and after completion, these resources can then be released or reduced.

Some of the examples of cloud computing are Google Slides, Google Drive, Dropbox, OneDrive etc.

Other Questions
Barnes & Noble and Amazon would be considered a(n) _______ because they sell similar products. Question 4 options: strategic group oligopoly overlapping group customer group The amortization of bond premium on long-term debt should be presented in a statement of cash flows (using the indirect method for operating activities) as a(n) Manipulate the radius and height of the cone, setting different values for each. Record the radius, height, and exact volume of the cone (in terms of ). The first one has been done for you. Also calculate the decimal value of the volume, and verify that it matches the volume displayed by the tool. (You might see some discrepancies in the tool due to rounding of decimals.) (1) Shipping along rivers is not as popular as it once was. (2) It is done by air and trucking on interstates. (3) Rivers still provide viable routes for shipping, but it is no longer the most feasible method for moving materials. (4) As rivers declined in popularity, other shipping methods took their place as the best ways to ship merchandise. Which sentence lacks a logical transition? One type of fabric costs $31.25 for 5 square yards. Another type of fabric costs $71.50 for 11square yards. Is the relationship between the number of square yards and the costproportional between the two types of fabric? Last Sunday, the average temperature was 8\%8%8, percent higher than the average temperature two Sundays ago. The average temperature two Sundays ago was TTT degrees Celsius. Which of the following expressions could represent the average temperature last Sunday? 10. Write a word problem for this equation:n ($25) = $125 To test the belief that sons are taller than their fathers, a student randomly selects 13 fathers who have adult male children. She records the height of both the father and son in inches and obtains the following data. Are sons taller than their fathers? Use the alphaequals0.10 level of significance. Note: A normal probability plot and boxplot of the data indicate that the differences are approximately normally distributed with no outliers.Height of Father Height of Son72.4 77.570.6 74.173.1 75.669.9 71.769.4 70.569.4 69.968.1 68.268.9 68.270.5 69.369.4 67.769.5 6767.2 63.770.4 65.5Which conditions must be met by the sample for this test? Select all that apply.A. The sample size is no more than 5% of the population size.B. The differences are normally distributed or the sample size is large.C. The sample size must be large.D. The sampling method results in a dependent sample.E. The sampling method results in an independent sample.Write the hypotheses for the test. UpperH 0 :H 1 :Calculate the test statistic. t 0=? (Round to two decimal places as needed.)Calculate the P-value. P-value=?(Round to three decimal places as needed.) Should the null hypothesis be rejected? Do not reject or Reject Upper H 0 because the P-value is less than or greater than the level of significance. There is or is not sufficient evidence to conclude that sons are the same height or are shorter than or are taller than or are not the same height as their fathers at the 0.10 level of significance. Click to select your answer(s). Often, myths are based on events that actually happened. How does a story become a myth rather than history? Historians decide that the event actually could have happened that way. As people retell the story, they add extra details to make the story more impressive. Once the story becomes part of history, people decide to add parts to it. A mythologist writes a book that includes a factual description of the event. Records indicate that x years after 2008, the average property tax on a three bedroom home in a certain community was T(x) =20x^2+40x+600dollars. Required:a. At what rate was the property tax increasing with respect to time in 2008? b. By how much did the tax change between the years 2008 and 2012? Sheridan Company, had 837000 shares of common stock issued and outstanding at December 31, 2017. On July 1, 2018, an additional 40600 shares of common stock were issued for cash. Sheridan also had unexercised stock options to purchase 31400 shares of common stock at $15 per share outstanding at the beginning and end of 2018. The average market price of Sheridan's common stock was $20 during 2018. What is the number of shares that should be used in computing diluted earnings per share for the year ended December 31, 2018 Identify the sentence that has the subordinating conjunction underlined and is punctuated correctly.A. Please take a few minutes to help me clean up, even if you feel you are too busy.B. We have to finish our work, before we can play a game.C. Although it is not fun to do chores everyone must do their share.D. You must finish your homework early because we have a busy night. What is the solution to this system of linear equations?y-x = 6y + x = -10(-2,-8)(-8.-2)(6.-10)(-10.6) Carlos is using the software development life cycle to create a new app. He has finished coding and is ready to see the output it produces. Which stage of the software development life cycle is Carlos ready for next? Coding Design Maintenance Testing Harry and Sally formed the Evergreen partnership by contributing the following assets in exchange for a 50 percent capital and profits interest in the partnership. Basis Fair Market Value Harry: Cash $30,000 $30,000 Land $100,000 $120,000 Totals $130,000 $150,000 Sally: Equipment used in business $200,000 $150,000 Totals $200,000 $150,000 a. How much gain or loss will Harry recognize on the contribution? b. How much gain or loss will Sally recognize on the contribution? c. Should Sally consider selling the property to the partnership rather than contributing it? A. YesB. No Solve for x. 3x-91>-87 AND 17x-16>18 Water pressurized to 3.5 x 105 Pa is flowing at 5.0 m/s in a horizontal pipe which contracts to 1/2 its former radius. a. What are the pressure and velocity of the water after the contraction This lesson focuses on changes in African nations in the twentieth century. Think about the African countries youve heard of. List as many of these countries as you can. in a republic, sovereign power is held by those who are eligible to_____, while political is exercised by the representatives chosen by the citizens. the perimeter of square is 76 cm find are of square