Skip to content
Snippets Groups Projects
Commit de001b33 authored by Mahboobe Shakeri's avatar Mahboobe Shakeri
Browse files

adding loops and conditions

parent f432a4e1
No related branches found
No related tags found
No related merge requests found
......@@ -5,18 +5,97 @@ public class Main {
public static void main(String[] args) {
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
// to see how IntelliJ IDEA suggests fixing it.
System.out.println("Hello Mahboobe local!");
int Mynumber = 25;
System.out.println("your number is : " + Mynumber);
//sep 18
for(int i=0; i<6;i++){
System.out.println(i);
}
Scanner sc = new Scanner(System.in);
System.out.println("Enter your name: ");
String name = sc.nextLine();
System.out.println("Enter your age: ");
int age = sc.nextInt();
System.out.println("Enter your height: ");
int height = sc.nextInt();
System.out.println("Your name is " + name + " and age is " + age + " and height is " + height);
int number=3;
// do{
// System.out.println("Enter positive number:");
// number= sc.nextInt();
//
// }while(number>0);
int sum =0;
while(number >0){
System.out.println("Enter positive number:");
number= sc.nextInt();
sum += number;
}
System.out.println("The sum is: "+sum);
sc.close();
// int i=0;
// while(i<6){
// System.out.println(i);
// i++;
// }
// int day = 2;
// switch (day) {
// case 1:
// System.out.println("Monday");
// break;
// case 2:
// System.out.println("Tuesday");
// break;
// case 3:
// System.out.println("Wednesday");
// break;
// case 4:
// System.out.println("Thursday");
// break;
// default:
// System.out.println("Invalid day");
// }
// String fruit = "orange";
// switch (fruit) {
// case "apple":
// System.out.println("You chose an apple.");
// break;
// case "banana":
// System.out.println("You chose a banana.");
// break;
// case "orange":
// System.out.println("You chose an orange.");
// break;
// default:
// System.out.println("Unknown fruit");
// }
// int age =
// 7;
// if( age >= 18){
// System.out.println("You are an adult");
// }else if(age > 12){
// System.out.println("You are a teenager");
// }else{
// System.out.println("You are a child");
// }
// System.out.println("Hello Mahboobe local!");
// int Mynumber = 25;
// System.out.println("your number is : " + Mynumber);
// Scanner sc = new Scanner(System.in);
// System.out.println("Enter your name: ");
// String name = sc.nextLine();
// System.out.println("Enter your age: ");
// int age = sc.nextInt();
//
// System.out.println("Enter your height: ");
// int height = sc.nextInt();
// System.out.println("Your name is " + name + " and age is " + age + " and height is " + height);
// sc.close();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment