SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 3 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 02 Jan 2018 My Price 10.00

method frequentFlier that accepts a Scanner for an input

I need help with these Questions. step by step instruction would be great.

Assignment 4(Total points 100)

 

Problem 1

Write a method frequentFlier that accepts a Scanner for an input file of ticket type / mileage pairs and reports how many frequent-flier miles the person earned.

  • 1 frequent flyer mile is earned for each mile traveled in coach.
  • 2 frequent flyer miles are earned for each mile traveled in first class.
  • 0 frequent flyer miles are earned on a discounted flight.

For example, given the input below, your method should return 15600 (2*5000 + 1500 + 100 + 2*2000).

firstclass  5000 coach   1500  coach

100 firstclass 2000  discount 300

 

 

Problem 2

Write a method printDuplicates that accepts a Scanner for an input file. Examine each line for consecutive occurrences of the same token on the same line and print each duplicated token along how many times it appears consecutively. For example the file:

 

hello how how are you you you you

I I I am Jack's Jack's smirking smirking smirking smirking smirking revenge

one fish two fish red fish blue fish

   bow  wow wow yippee yippee   yo yippee   yippee yay  yay yay

leads to the following console output:

how*2 you*4

I*3 Jack's*2 smirking*5

 

wow*2 yippee*2 yippee*2 yay*3

 

Problem 3

Write a method named coinFlip that accepts a Scanner for an input file of coin flips that are heads (H) or tails (T). Consider each line to be a separate set of coin flips and output the number and percentage of heads in that line. If it is more than 50%, print "You win!". Consider the following file:

 

H T H H T

T t    t  T h  H

      h

For the input above, your method should produce the following output:

3 heads (60.0%)

You win!

 

2 heads (33.3%)

 

1 heads (100.0%)

You win!

 

Problem 4

Write a method named flipLines that accepts a Scanner for an input file and writes to the console the same file's contents with each pair of lines reversed in order. For example, if the file contains:

 

Twas brillig and the slithy toves

did gyre and gimble in the wabe.

All mimsey were the borogroves,

and the mome raths outgrabe.

 

The End

your method should produce the following output:

did gyre and gimble in the wabe.

Twas brillig and the slithy toves

and the mome raths outgrabe.

All mimsey were the borogroves,

The End

 

Problem 5

 

Write a static method called runningSum that accepts as a parameter a Scanner holding a sequence of real numbers and that outputs the running sum of the numbers followed by the maximum running sum. For example if the Scanner contains the following data:

3.25 4.5 -8.25 7.25 3.5 4.25 -6.5 5.25

Your method should produce the following output:

running sum = 3.25 7.75 -0.5 6.75 10.25 14.5 8.0 13.25

max sum = 14.5

 

Attachments:

Answers

(5)
Status NEW Posted 02 Jan 2018 02:01 PM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)