This commit is contained in:
2024-09-13 10:20:45 +02:00
parent 16fc065973
commit c85b188fa8
5 changed files with 66 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

View File

@ -2,6 +2,7 @@ package com.example;
import java.util.Scanner; import java.util.Scanner;
public class BasicII { public class BasicII {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Hello world!"); System.out.println("Hello world!");
@ -70,6 +71,70 @@ public class BasicII {
System.out.println("Free"); System.out.println("Free");
} }
Welcome();
/*
You are making an automated response program for a store.
The bot should take a number from the user as input and reply with an automated message.
There are currently 3 responses, that you need to a handle:
User message: "1", Reply: "Order confirmed"
User message: "2", Reply: "info@sololearn.com"
For any other number, the reply should be: "Try again".
The given code calls a method called bot(). Define the method, which should take an integer input from the user, and handle the above mentioned cases, by outputting the corresponding reply.
Do not change the method call in main().
*/
bot();
/*
You need to make a method that converts a foot value to inches.
1 foot has 12 inches.
Define a convert() method, that takes the foot value as its argument and outputs the inches value.
The result must be a double.
*/
double num = sc.nextDouble();
convert(num);
/*
You are making a Celsius to Fahrenheit converter.
Write a method to take the Celsius value as an argument and return the corresponding Fahrenheit value.
Sample Input
36
Sample Output
96.8
The given code takes the celsius value as input and passes it to a fahr() method, which you need to create.
*/
double c = sc.nextDouble();
System.out.println(fahr(c));
} }
static double fahr(double cels){
return 1.8*cels+32;
}
static void convert(double nm){
System.out.println(nm*12);
}
static void Welcome(){
System.out.println("Welcome!!");
}
static void bot(){
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
switch (num) {
case 1:
System.out.println("Order confirmed");
break;
case 2:
System.out.println("info@sololearn.com");
break;
default:
System.out.println("Try again");
break;
}
}
} }

1
CertificateLink.txt Normal file
View File

@ -0,0 +1 @@
https://www.sololearn.com/certificates/CC-WHOYREFK

Binary file not shown.