You 9:59 (Edited)
Good morning madamPriya Nair 10:00
Good Morning everyone
Aswathy Ammu 10:00
Good morning madam
sreeji's Notetaker (Otter.ai) 10:03
Hi, I'm an AI assistant helping sreeji krishnan take notes for this meeting. Follow along the transcript here: https://otter.ai/u/4x68bkVUcE2ZaLDxoHpq7pdxVpA?utm_source=va_chat_link_1
You'll also be able to see screenshots of key moments, add highlights, comments, or action items to anything being said, and get an automatic summary after the meeting.
Sreeji Krishnan 10:03
good morning all
Amarjith 10:03
Good morning sir/ma'am
Priya Nair 10:08
- Input: An integer (positive or negative)
- Output: “Number is positive”, "Number is negative", "Number is zero
Paste your code here in the chat window
Visal 10:16
not screenshot. just copy and paste the code
Aswathy Ammu 10:17
public class number {
public static void main(String[] args) {
int num = 1;
if (num > 0) {
System.out.println("Number is postive");
} else if (num < 0) {
System.out.println("Number is negative");
} else {
System.out.println("Number is zero");
}
}
}
You 10:17
public class DataExample {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter an integer: ");
int number = scanner.nextInt();
if (number > 0) {
System.out.println("Number is positive");
} else if (number < 0) {
System.out.println("Number is negative");
} else {
System.out.println("Number is zero");
}
scanner.close();
}
}
Priya Nair 10:19
Checking if a number is both positive and even:
Modify that same program
You 10:25
public class EvenExample {
public static void main(String[] args) {
int number = 2;
if (number % 2 == 0) {
System.out.println("Postive");
} else {
System.out.println("Even");
}
}
}
Priya Nair 10:26
number is both positive and even:
Aswathy Ammu 10:27
public class number {
public static void main(String[] args) {
int num = 2;
if (num > 0) {
System.out.println("number is both positive");
}
else if (num % 2 == 0) {
System.out.println("number is not both positive");
}
}
}
You 10:28
public class DataExample {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter an integer: ");
int number = scanner.nextInt();
if (number > 0) {
System.out.println("Number is positive and even");
} else if (number < 0) {
System.out.println("Number is negative");
} else {
System.out.println("Number is zero");
}
scanner.close();
}
}
Priya Nair 10:30
need to check for 2 conditions
if it is positive and then if it is even
try to do it in one conditional statement
using && operator
Aswathy Ammu 10:34
public class number {
public static void main(String[] args) {
int num = 8;
if (num > 0 && num % 2 == 0) {
System.out.println("Number is positive and even");
} else if (num > 0 && num % 2 != 0) {
System.out.println("Number is positive but odd");
} else if (num < 0) {
System.out.println("Number is negative");
} else {
System.out.println("Number is zero");
}
}
}
You 10:36
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter an integer: ");
int number = scanner.nextInt();
if (number > 0 && number % 2 == 0) {
System.out.println("Number is positive and even");
} else if (number > 0) {
System.out.println("Number is positive");
} else if (number < 0) {
System.out.println("Number is negative");
} else {
System.out.println("Number is zero");
}
}
Priya Nair 10:42
import java.util.Scanner;
public class Example {
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.print("Enter an integer: ");
int number = scanner.nextInt();
if (number > 0 && number % 2 == 0) {
System.out.println("Number is positive and even");
} else if (number > 0 && number % 2 != 0) {
System.out.println("Number is positive but odd");
} else if (number < 0) {
System.out.println("Number is negative");
} else {
System.out.println("Number is zero");
}
}
}
Can you modify your program to compare the greatest of 3 numbers
Priya Nair 10:42
Hope you understood ?
You 10:43
Yes madam, l understand
Aswathy Ammu 10:43
yes madam
Priya Nair 10:43
- Input:
Input the 1st number: 45
Input the 2nd number: 68
Input the 3rd number: 86
- Output: “The greatest Number is “ (the greatest number
Visal 10:43
please copy this code and modify in it
Aswathy Ammu 10:51
public class Greater {
public static void main(String[] args) {
Scanner sr = new Scanner(System.in);
System.out.println("Input 1st number:");
int num1 = sr.nextInt();
System.out.println("Input 2nd number:");
int num2 = sr.nextInt();
System.out.println("Input 3rd number:");
int num3 = sr.nextInt();
int greater;
if (num1>=num2 && num1>=num3){
greater =num1;
} else if (num2>=num1 && num2>=num3){
greater = num2;
} else {
greater = num3;
}
System.out.println("The greatest number is: " + greater);
}
}
You 10:53
public static void main(String[] args) {
int number = 86;
if (number < 45) {
System.out.println("The greatest Number then 45");
} else if (number < 68) {
System.out.println("The greatest Number then 68");
} else if (number > 86) {
System.out.println("The greatest Number then 86");
} else {
System.out.println("The greatest then 86");
}
}
Priya Nair 10:54
Khayoom
Can you try once more
there are 3 numbers
You 10:55
okay madam
Priya Nair 10:55
you have to compare them to find the greatest
like is num1 greater than num2 and if it is greater than num3 also - in this way
if (num1 > num2)
if (num1 > num3)
or
if (num1 > num2 && num1 > num3)
Visal 11:03
Khayoom?
You 11:04
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Input the 1st number: ");
int num1 = sc.nextInt();
System.out.println("Input the 2nd number: ");
int num2 = sc.nextInt();
System.out.println("Input the 3rd number: ");
int num3 = sc.nextInt();
int great;
if (num1 > num2 && num1 > num3) {
great = num1;
} else if (num2 > num1 && num2 > num3) {
great = num2;
} else {
great = num3;
}
System.out.println("The greatest number is : " + great);
}
Priya Nair 11:05
Good job both Aswathy and Khayoom
Aswathy Ammu 11:05
Thank you madam..
Priya Nair 11:06
Can I give you 2 more problem with increased complexity, which maybe you can solve and share it with me later
You 11:06
Thank you madam..
Priya Nair 11:06
this is the first one -
- Input: Student's score (out of 100).
- Grade slabs:
- 90–100: A
- 80–89: B
- 70–79: C
- 60–69: D
- Below 60: F
- 90–100: A
- Output: Assigned grade
Give a exam score as input
which can be any number between 0 to 100
You have to check that number and assign a grade
based on the grade slabs provided
and then print the grade that the student received as output
Clear?
Aswathy Ammu 11:09
yes madam..
Priya Nair 11:09
Ok
You 11:09
Yes madam
Priya Nair 11:09
Here is the second one -
Write a program to input electricity unit charges and calculate total electricity bill according to the given condition:
For first 50 units Rs. 0.50/unit
For next 100 units Rs. 0.75/unit
For next 100 units Rs. 1.20/unit
For unit above 250 Rs. 1.50/unit
An additional surcharge of 20% is added to the bill
So you have to provide a unit as input to the program
which is the consumption of a house
it could any number between 0 and 1000
and then based on the conditions you need to calculate the charges
For first 50 units Rs. 0.50/unit
For example -
if the unit consumed is 345
then first 50 would be Rs. 0.50/unit
so 345-50= 295
in that 295, next 100 untis would be Rs. 0.75/unit
Priya Nair 11:14
295-100 = 195
in that 195, next 100 units Rs. 1.20/unit
195 - 100 = 95
which would be above 250
and hence should charged at Rs. 1.50/unit
50 * 0.50
100 * 0.75
100 * 1.20 -
(units-250) * 1.50
Also
An additional surcharge of 20% is added to the bill
Whatever charges you get after applying the conditions
calculate 20% of that charge
Priya Nair 11:19
and then add it to the charge
which will be the final bill amount
Priya Nair 11:20
Clear?
You 11:21
l some understand madam
Aswathy Ammu 11:21
I understood
Visal 11:20
Got it Ma'am, We shall explain to them
Priya Nair 11:21
The solution is simple
but understanding the problem is critical
Comments
Post a Comment