├── README.md ├── Sum of Even Numbers till N Send Feedback Given a number N, print sum of all even numbers from 1 to N. ├── Number Pattern 1 Send Feedback Print the following pattern Pattern for N = 4 1 23 345 4567 ├── Find Character Case Send Feedback Write a program to determine whether the entered character is in uppercase or lowercase, or is an invalid character. ├── Fahrenheit to Celsius Table Send Feedback Given three values - Start Fahrenheit Value (S), End Fahrenheit value (E) and Step Size (W), you need to convert all Fahrenheit values from Start to End at the gap of W, into their corresponding Celsius values and print the table. ├── Star Pattern Send Feedback Print the following pattern Pattern for N = 4 * *** ***** ******* ├── Number Pattern 2 Send Feedback Print the following pattern Pattern for N = 4 1 23 345 4567 ├── Write a program to input name (as a single character) and marks of three tests of a student (all integers). Then calculate and print the name and average (integer) of all test marks. All the test marks are integers and calculate average also as integer. That is, you need to print the integer part of average only, neglect the decimal part. ├── Sum of even & odd Send Feedback Write a program to input an integer N and print the sum of all its even digits and sum of all its odd digits separately. Digits means numbers not the places. That is, if the given integer is "13245", even digits are 2 & 4 and odd digits are 1, 3 & 5. Input format : Integer N Output format : Sum_of_Even_Digits Sum_of_Odd_Digits (Print first even sum and then odd sum separated by space) └── Total Salary Send Feedback Write a program to calculate the total salary of a person. The user has to enter the basic salary (an integer) and the grade (an uppercase character), and depending upon which the total salary is calculated as - totalSalary = basic + hra + da + allow – pf where : hra = 20% of basic da = 50% of basic allow = 1700 if grade = ‘A’ allow = 1500 if grade = ‘B’ allow = 1300 if grade = ‘C' or any other character pf = 11% of basic. /README.md: -------------------------------------------------------------------------------- 1 | # coding-ninjas-introduction-to-java 2 | learning github 3 | -------------------------------------------------------------------------------- /Sum of Even Numbers till N Send Feedback Given a number N, print sum of all even numbers from 1 to N.: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Solution 4 | { 5 | public static void main(String[] args) 6 | { 7 | Scanner s= new Scanner(System.in); 8 | int n=s.nextInt(); 9 | int sum=0; 10 | int i=1; 11 | while(i<=n) 12 | { 13 | if(i%2==0) 14 | sum+=i; 15 | i++; 16 | } 17 | System.out.println(sum); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Number Pattern 1 Send Feedback Print the following pattern Pattern for N = 4 1 23 345 4567: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class Solution 3 | { 4 | 5 | public static void main(String[] args) 6 | { 7 | Scanner s =new Scanner(System.in); 8 | int n=s.nextInt(); 9 | int i=1; 10 | while(i<=n) 11 | { 12 | int val=i; 13 | int j=1; 14 | while(j<=i) 15 | { 16 | System.out.print(val); 17 | val++; 18 | j++; 19 | } 20 | System.out.println(""); 21 | i++; 22 | } 23 | 24 | } 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Find Character Case Send Feedback Write a program to determine whether the entered character is in uppercase or lowercase, or is an invalid character.: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class Main 3 | { 4 | 5 | public static void main(String[] args) 6 | { 7 | Scanner c=new Scanner(System.in); 8 | String str=c.next(); 9 | char a=str.charAt(0); 10 | if(a>=97 && a<=122) 11 | { 12 | System.out.println("0"); 13 | }else 14 | if(a>=65 && a<=90) 15 | { 16 | System.out.println("1"); 17 | }else 18 | { 19 | System.out.println("-1"); 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Fahrenheit to Celsius Table Send Feedback Given three values - Start Fahrenheit Value (S), End Fahrenheit value (E) and Step Size (W), you need to convert all Fahrenheit values from Start to End at the gap of W, into their corresponding Celsius values and print the table.: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class Solution 3 | { 4 | public static void main(String[] args) 5 | { 6 | Scanner a=new Scanner(System.in); 7 | int S=a.nextInt(); 8 | int E=a.nextInt(); 9 | int W=a.nextInt(); 10 | int c; 11 | while(S<=E) 12 | { 13 | c=(5*(S-32))/9; 14 | System.out.println(S+"\t"+c); 15 | S=S+W; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Star Pattern Send Feedback Print the following pattern Pattern for N = 4 * *** ***** *******: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class Solution 3 | { 4 | public static void main(String[] args) 5 | { 6 | Scanner s =new Scanner(System.in); 7 | int n=s.nextInt(); 8 | int i=0; 9 | int val=1; 10 | while(i0) 11 | { 12 | digit=num%10; 13 | num=num/10; 14 | if(digit%2!=0) 15 | odd=odd+digit; 16 | else 17 | ev=ev+digit; 18 | } 19 | System.out.print(ev+" "+odd); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Total Salary Send Feedback Write a program to calculate the total salary of a person. The user has to enter the basic salary (an integer) and the grade (an uppercase character), and depending upon which the total salary is calculated as - totalSalary = basic + hra + da + allow – pf where : hra = 20% of basic da = 50% of basic allow = 1700 if grade = ‘A’ allow = 1500 if grade = ‘B’ allow = 1300 if grade = ‘C' or any other character pf = 11% of basic.: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.lang.Math; 3 | public class Main 4 | { 5 | public static void main(String[] args) 6 | { 7 | Scanner s=new Scanner(System.in); 8 | int bs=s.nextInt(); 9 | String str=s.next(); 10 | char c=str.charAt(0); 11 | int all; 12 | if(c==65) 13 | { 14 | all=1700; 15 | } 16 | else if(c==66) 17 | { 18 | all=1500; 19 | } 20 | else 21 | { 22 | all=1300; 23 | } 24 | double ts=((bs+(0.20*bs)+(0.50*bs)+all)-(0.11*bs)); 25 | double p=Math.round(ts); 26 | int h=(int)(p); 27 | System.out.println(h); 28 | } 29 | } 30 | --------------------------------------------------------------------------------