1.0.1 • Published 3 years ago

internet-booth v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Internet Booth

Description

Calculate the amount to pay in an Internet booth, taking into account that the cost per hour is USD 1.00 and for every 5 hours they give you one hour of free promotion.

Solution

class Internet
{
    constructor(pnumberofhoursconsumed)
    {
        this.numberofhoursconsumed=pnumberofhoursconsumed;
    }
    amount_to_pay=()=>
    {
        let promotion=0;
        let pay=0;
        promotion=Math.trunc(this.numberofhoursconsumed/5);
        pay=this.numberofhoursconsumed-promotion;
        return {pay,promotion};

    }
   
}

Usage

 let Internet=require("./Internet").Internet;

 let internet=new Internet(15);
 let calc=internet.amount_to_pay();
 console.log("You must pay USD "+calc.pay+" per "+ internet.numberofhoursconsumed+" internet hours");
1.0.1

3 years ago

1.0.0

3 years ago