-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVeckan5_methoder_o9.java
More file actions
48 lines (37 loc) · 1.39 KB
/
Veckan5_methoder_o9.java
File metadata and controls
48 lines (37 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
9. Skapa en funktion som beräknar kostnaden för en hotellgäst.
Funktionen har argumenten days och price, där price har ett
default-värde på 600kr (d.v.s. om inget pris anges så beräknas
hotellkostande utifrån rumspriset 600).
*/
package veckan5_o9_methoder;
import java.util.Scanner;
/**
*
* @author wiktorialipkowska
*/
public class Veckan5_o9_methoder {
public static void hotel(int days, double price ){
System.out.println("How many night?");
Scanner input = new Scanner(System.in);
int numberNights = input.nextInt();
System.out.println("Use default price for one night stay? Y? N?");
Scanner input2 = new Scanner(System.in);
String priceDefault = input2.nextLine();
if (!"N".equals(priceDefault) && !"n".equals(priceDefault)){
double result = numberNights*600;
System.out.println("Cost of your stay is: " + result);}
else {
System.out.println("Please provide a price for one night.");
Scanner input3 = new Scanner(System.in);
double priceToPay = input3.nextDouble();
double result2 = numberNights*priceToPay;
System.out.println("Cost of your stay is: " + result2);}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
hotel(1,1);
}
}