Question: Beginner JAVA in Eclipse (Scanners, boolean, for loops, if, methods) Assignment: The Metaway Corporation has hired you to write a program that allows users to

Beginner JAVA in Eclipse (Scanners, boolean, for loops, if, methods)

Assignment:

The Metaway Corporation has hired you to write a program that allows users to order streaming video services like Hulu, Netflix and Prime from one site. Users first enter the number of months they wish to order followed by opting in to each of the three services:

********************MetaCorp Streaming Service********************* Enter number of months on subscription: 8 Do you want Hulu ($8/month) [y = yes, anything else = no] : y 
Do you want Netflix ($10/month) [y = yes, anything else = no] : y 
Do you want Prime ($7/month) [y = yes, anything else = no] : n 
******************************************************************* 
Hulu and Netflix for 8 months is $144. 

To handle the y/n questions, try something like

String myInput = myScanner.next(); boolean hasNetflix = (myInput.equals("y")); 

then later

if (hasNetflix) { total = total + 10; } 

Note that it is expected that the word months will be plural even if the user enters 1 for the number of months.

If the user enters something other than a positive integer for months your programs behavior can be arbitrary: fail with an error, hang indefinitely, reprompt, etc.

Nonfunctional requirements You must write a method String stars(int n) which takes a positive integer as input and returns of string of that many stars. It returns an empty string of the integer is zero or negative. You must call that method to generate the asterisks in the program output, as shown above.

My code so far:

import java.util.Scanner;

public class Assignment3

{

public static void main(String[]args)

{

Scanner input = new Scanner(System.in);

System.out.println("********************MetaCorp Streaming Service*********************");

System.out.print("Do you want Hulu ($8/month) [y = yes, anything else = no] :");

String hulu = input.next();

boolean wantsHulu = (input.equals("y"));

System.out.print("Do you want Netflix ($10/month) [y = yes, anything else = no] :");

String netflix = input.next();

boolean wantsNetflix = (input.equals("y"));

System.out.print("Do you want Prime ($7/month) [y = yes, anything else = no] :");

String prime = input.next();

boolean wantsPrime = (input.equals("y"));

System.out.println("*******************************************************************");

int total=0;

if (wantsHulu)

{

total = total + 8;

}

if (wantsNetflix)

{

total = total + 10;

}

if (wantsPrime)

{

total = total + 7;

}

input.close();

}

}

Please help, thank you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!