Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Program
- {
- public static void main(String[] args) {
- Scanner sc=new Scanner(System.in);
- //targil 2
- final int charToInt ='0';//שומר הקבוע את המספר של אות '0'
- System.out.println("Please enter three numbers from 0 to 9 divided by space");
- int ch1=sc.next().charAt(0);// ch1 מקבל מספר של אות שקראנו בעזרת scanner
- int ch2=sc.next().charAt(0);
- int ch3=sc.next().charAt(0);
- System.out.println((ch1-charToInt)*100 + (ch2-charToInt)*10 + (ch3-charToInt));
- //targil 3
- int abLength ='Z'-'A'+1;//in this case better to do like this
- System.out.println("English Alpabet length is: "+ abLength );
- //targil 4
- final double startCost = 10.2;
- final double perKM=1.3;
- final double perBag=2.0;
- System.out.println("Please enter length of trip and amount of bags divided by Space");
- int tripLength = sc.nextInt();
- int bags=sc.nextInt();
- System.out.println("Total price: "+(startCost + tripLength*perKM + bags*perBag));
- //targil5
- final int station = 5;
- final int between = 3;
- System.out.println("Enter your start position, lift start position, and the floor you need to arrive divided by Space");
- int myStartPosition=sc.nextInt();
- int liftStartPosition=sc.nextInt();
- int goal=sc.nextInt();
- System.out.println("Tatal time in seconds: "+((liftStartPosition-myStartPosition)*between+station+(goal-myStartPosition)*between));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement