Finished
This commit is contained in:
BIN
44adc3e1-bbc6-46b2-8bb3-633ad4cdccc2.jpg
Normal file
BIN
44adc3e1-bbc6-46b2-8bb3-633ad4cdccc2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 84 KiB |
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Binary file not shown.
1
CertificateLink.txt
Normal file
1
CertificateLink.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://www.sololearn.com/certificates/CC-WHOYREFK
|
BIN
bdb9720d-bbf1-488e-9d94-0d16f18896e9.pdf
Normal file
BIN
bdb9720d-bbf1-488e-9d94-0d16f18896e9.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user