🔒 Closed pahelp po

Status
Not open for further replies.

Phrog

Forum Veteran
Nag kakaroon po ako ng error dito sa pag compute ng tour price per person(tppp) at sa percent
eto po yung error na lumalabas. Kanina ko pa po tinatry ayusin yan, kaso wala di ko matapos
Code:
Hotel_Reservation.java:64: error: incompatible types: possible lossy conversion from double to int
        dis = (tppp * percent[pcode])/100;
eto po yung code nung array ng percent
Code:
String [] discount = {"", "> 5 PERSON", "<= 5 BUT NOT < TO 10", "<= 10 BUT < TO 20"};
        double [] percent = {0, 0.02, 0.05, 0.10};
kaya po di ko macompute yung tppp*percent[pcode]

Code:
import java.util.Scanner;
public class Hotel_Reservation {
    
    public static void main(String[] args) {
        String name;
        int lcode, tcode, fcode, days, persons, tp, tpd, dis, np, tppp, pcode;
        //LOCATION
        String [] loc = {"", "TANAY RIZAL", "CEBU CITY", "CALAMBA LAGUNA", "BATANGAS CITY", "BAGUIO CITY"};
        String [] ltype = {"", "MOUNTAIN", "LOCAL PRODUCT", "LOCAL PRODUCT", "BEACHES", "MOUNTAIN"};
        int [] eprice = {0, 500, 600, 450, 550, 700};
        
        //TOUR GUIDE
        String [] tguide = {"", "LEO PONTIS", "MARIA MAKI", "JOSIE JESUS", "HANEY JANE", "JERSON RICE"};
        int [] trate = {0, 350, 340, 330, 350, 370};
        
        //FOOD CODE
        String [] food = {"", "FOOD ONLY", "ACCOMODATION ONLY", "FOOD & ACCOMODATION", "NONE"};
        int [] famount = {0, 250, 500, 700, 0};
        
        //DISCOUNT
        String [] discount = {"", "> 5 PERSON", "<= 5 BUT NOT < TO 10", "<= 10 BUT < TO 20"};
        double [] percent = {0, 0.02, 0.05, 0.10};
        
        Scanner sc = new Scanner(System.in);
        
        System.out.print("=====HOTEL RESERVATION=====");
        System.out.println("\n");
        System.out.print("INPUT TOURIST NAME: ");
        name = sc.nextLine();
        System.out.println("\n");
        
        System.out.println("***************************");
        System.out.print("INPUT LOCATION CODE: ");
        lcode = sc.nextInt();
        System.out.print("INPUT TOUR CODE: ");
        tcode = sc.nextInt();
        System.out.print("INPUT FOOD CODE: ");
        fcode = sc.nextInt();
        System.out.print("HOW MANY PERSON?: ");
        persons = sc.nextInt();
        System.out.print("PERCENTAGE: ");
        pcode = sc.nextInt();
        System.out.print("HOW MANY DAYS?: ");
        days = sc.nextInt();
        
        System.out.print("***************************");
        System.out.println("\n");
        System.out.println("LOCATION OF TOUR: "+loc[lcode]);
        System.out.println("LOCATION TYPE: "+ltype[lcode]);
        System.out.println("ENTRY PRICE: "+eprice[lcode]);
        System.out.println("TOUR GUIDE: "+tguide[tcode]);
        System.out.println("TOUR GUIDE RATE: "+trate[tcode]);
        System.out.println("PERCENTAGE: "+percent[pcode]);
        System.out.println("FOOD: "+food[fcode]);
        System.out.println("FOOD AMOUNT: "+famount[fcode]);
        System.out.println("\n");
    
        //COMPUTATION
        tp = eprice[lcode] + trate[lcode] + famount[fcode];
        tpd = tp * days;
        tppp = tpd * persons;
        dis = (tppp * percent[pcode])/100;
        np = tppp - dis;
        System.out.println("**************************************************");
        System.out.println("YOUR TOUR PRICE IS: "+tp);
        System.out.println("YOUR TOUR PRICE PER DAYS IS: "+tpd);
        System.out.println("DISCOUNT: "+dis);
        System.out.println("NET PRICE: "+np);
        System.out.println("\n");
        System.out.println("*************ENJOY YOUR ****ING DAY***************");
    }
}

Salamat po
 
Status
Not open for further replies.

About this Thread

  • 4
    Replies
  • 480
    Views
  • 3
    Participants
Last reply from:
aa1012

Trending Topics

Online now

Members online
449
Guests online
1,935
Total visitors
2,384

Forum statistics

Threads
2,290,569
Posts
29,065,186
Members
1,212,400
Latest member
Ms_Lou07
Back
Top