It is Question: Creating a program for a market. The system can send a family card to a consumer and accept a discount of 0% (no discount), 5%, or 10% based on the following rules: The default discount choice is "no discount." There is no discount for unregistered users. A family card is not supplied to an unregistered user. If a registered user has spent more than $1000 on past food purchases and has less than 19 shopping sessions, they will receive a 5% discount. If a registered user spent more than $1000 in prior grocery shopping sessions and had at least 20 grocery shopping sessions, they would receive a 10% discount. Only registered users who spend over $1000 or have at least 20 shopping sessions receive a family card.   My program works just fine. It meets the conditions in the question. But my problem is I can't run Junit tests no matter how hard I try. According to my program, can you write Junit test and post the Junit test codes?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

It is Question: Creating a program for a market. The system can send a family card to a consumer and accept a discount of 0% (no discount), 5%, or 10% based on the following rules:

  1. The default discount choice is "no discount."
  2. There is no discount for unregistered users. A family card is not supplied to an unregistered user.

If a registered user has spent more than $1000 on past food purchases and has less than 19 shopping sessions, they will receive a 5% discount.

  1. If a registered user spent more than $1000 in prior grocery shopping sessions and had at least 20 grocery shopping sessions, they would receive a 10% discount.

  2. Only registered users who spend over $1000 or have at least 20 shopping sessions receive a family card.

 

My program works just fine. It meets the conditions in the question. But my problem is I can't run Junit tests no matter how hard I try. According to my program, can you write Junit test and post the Junit test codes?

public static int discounts(int spent, int market_sessions)
{
int discount=0;
if(spent>1000)
{
if(market_sessions<=19)
discount=5;
else
discount=10;
}
return discount;
public static int userType(int a)
{
System.out.println("Enter 1 or 2");
System.out.println("1 = Registered User");
System.out.println("2 = Unregistered User");
Scanner scan3 =new Scanner(System.in);
a=Integer.parseInt(scan3.nextLine());
vwhile(a<1 || a>2) {
System.out.println("Enter 1 or 2");
System.out.println("1 = Registered User");
System.out.println("2 = Unregistered User");
Scanner scan4 =new Scanner(System.in);
a=Integer.parseInt(scan4.nextLine());
}
return a;
}
Transcribed Image Text:public static int discounts(int spent, int market_sessions) { int discount=0; if(spent>1000) { if(market_sessions<=19) discount=5; else discount=10; } return discount; public static int userType(int a) { System.out.println("Enter 1 or 2"); System.out.println("1 = Registered User"); System.out.println("2 = Unregistered User"); Scanner scan3 =new Scanner(System.in); a=Integer.parseInt(scan3.nextLine()); vwhile(a<1 || a>2) { System.out.println("Enter 1 or 2"); System.out.println("1 = Registered User"); System.out.println("2 = Unregistered User"); Scanner scan4 =new Scanner(System.in); a=Integer.parseInt(scan4.nextLine()); } return a; }
package Market;
import java.util.Scanner;
public class Lab5
{
public static void main(String[] args)
{
int spent=0;
int market_sessions=0;
Scanner scan =new Scanner(System.in);
System.out.printf("Amount spent by customer: ");
spent=Integer. parseInt(scan.nextLine());
Scanner scan2 =new Scanner(System.in);
System.out.printf("Marketsessions
market_sessions=Integer.parseInt(scan2.nextLine());
the customer: ");
int a = 0;
int type=userType(a);
if(type==1)
{
int discount=discounts(spent, market_sessions);
System.out.println("Discount: "+discount);
if(spent>1000 || market_sessions>=20)
System.out.println("Family card is sent to the customer");
}
else
{
System.out.println("Family cards and discounts are not given to unregistered user
}
Transcribed Image Text:package Market; import java.util.Scanner; public class Lab5 { public static void main(String[] args) { int spent=0; int market_sessions=0; Scanner scan =new Scanner(System.in); System.out.printf("Amount spent by customer: "); spent=Integer. parseInt(scan.nextLine()); Scanner scan2 =new Scanner(System.in); System.out.printf("Marketsessions market_sessions=Integer.parseInt(scan2.nextLine()); the customer: "); int a = 0; int type=userType(a); if(type==1) { int discount=discounts(spent, market_sessions); System.out.println("Discount: "+discount); if(spent>1000 || market_sessions>=20) System.out.println("Family card is sent to the customer"); } else { System.out.println("Family cards and discounts are not given to unregistered user }
Expert Solution
steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY