Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 7

package FlowControlprograms;

import java.util.Scanner;
//Write a Program to check the given number is positive ,negative ,zero
public class Fc_Assignment1A {

public static void main(String[] args) {


Scanner s = new Scanner(System.in);
System.out.print("Enter the Number:");
int num=s.nextInt();
if(num>0)
{
System.out.println("Positive");
}
else if(num<0)
{
System.out.println("Negative");
}
else
{
System.out.println("Zero");
}

===========================================================
package FlowControlprograms;
import java.util.Scanner;
//Given two non-negative int values,print true if they have the same last
digit,such as with 27 and 57

public class Fc_Assignment1B {

public static void main(String[] args) {

// TODO Auto-generated method stub


Scanner s =new Scanner(System.in);
int n1=s.nextInt();
int n2=s.nextInt();
n1=n1%10;
n2=n2%10;
boolean res=n1==n2;
System.out.println(res);

}
======================================================
package FlowControlprograms;
import java.util.Scanner;
//Write a program to check if a given integer is odd or even
public class Fc_Assignment2 {

public static void main(String[] args) {


Scanner s = new Scanner(System.in);
System.out.print("Enter the Number:");
int num=s.nextInt();
if(num%2==0)
{
System.out.println("even");
}
else
{
System.out.println("odd");
}

}
============================================================
package FlowControlprograms;
//Write a program to check if the program has received command line arguments or
not
//if the program has not received arguments then print "No Values",else print all
the values in a single line separated by ,

public class Fc_Assignment3 {

public static void main(String[] args) {


if(args.length==0)
{
System.out.println("No values");
}
else
{
for(String name:args) {
System.out.println(name+" ");
}
}

}
==============================================================
package FlowControlprograms;
//Initialize two characters variables in a program and display the character in
alphabetical order
public class Fc_Assignment4 {

public static void main(String[] args) {


char var1='s';
char var2='e';
if(var1>var2)
{
System.out.println(var2+" "+var1);
}
else
{
System.out.println(var1+" "+var2);
}

}
}
=====================================================================
package FlowControlprograms;
//Initialize a character variable in a program and print 'Alphabet' if the
initialized value is an alphabet,print 'Digit'if the initailized value is
number,and print 'Special Charcter',if the initialized value in anything else.

public class Fc_Assignment5 {

public static void main(String[] args) {


char var='@';
if((var>=65 && var<=90)||(var>97&&var<=122)){
System.out.println("Alphabet");
}
else if(var>=48 &&var<=57) {
System.out.println("Number");
}
else
{
System.out.println("Special Charcter");
}

}
=============================================================
package FlowControlprograms;
//Write a program to accept gender ("Male"or"Female") and age from command line
arguments and print the percentage of interest based on the given condition.
//if the gender is 'Female'and age is between 1 and 58,the percentage of interest
is 8.2%
//if the gender is 'Female'and age is between 59and 100,the percentage of interest
is 9.2%
//if the gender is 'Male'and age is between 1 and 58,the percentage of interest is
8.4%
//if the gender is 'Male'and age is between 59 and 100,the percentage of interest
is 10.5%
public class Fc_Assignment6 {

public static void main(String[] args) {


int age=Integer.parseInt(args[1]);
if(args[0].equals("Female"))
{
if(age>=1 && age<=58) {
System.out.println("the percentage of interest is 8.2%");
}
else
{
System.out.println("the percentage of interest is 9.2%");
}
}
else
{
if(age>=1 && age<=58) {
System.out.println("the percentage of interest is 8.4%");

}
else
{
System.out.println("the percentage of interest is 10.5%");
}
}
}

}
==================================================================
package FlowControlprograms;
//Initialize a character variable with an alphabet in a program.
//if the charcter value is in lowercase,the output should be displayed in
uppercase in the following format.
public class Fc_Assignment7 {

public static void main(String[] args) {


char var='a';
if(var >='a'&& var<='z') {
System.out.println((char)(var-32));
}
else
{
System.out.println((char)(var+32));
}
}

}
======================================================================
package FlowControlprograms;
import java.util.Scanner;
//write a program to receive a color code from the user(an Alphabet).

public class Fc_Assignment8 {

public static void main(String[] args) {


Scanner s=new Scanner(System.in);
System.out.println("Enter color code:");
char color=s.next().charAt(0);
switch(color) {
case 'R':
case 'r':
System.out.println("Red");
break;
case 'B':
case 'b':
System.out.println("Blue");
break;
case 'G':
case 'g':
System.out.println("Green");
break;
case 'O':
case 'o':
System.out.println("Orange");
break;
case 'W':
case 'w':
System.out.println("White");
break;
default :
System.out.println("Invalid Code");
}

}
===========================================================
package FlowControlprograms;
//write a program to receive a number and print the corresponding month name.
public class Fc_Assignment9 {

public static void main(String[] args) {


switch(args[0])
{
case "1":
System.out.println("January");
break;
case "2":
System.out.println("Febrauary");
break;
case "3":
System.out.println("March");
break;
case "4":
System.out.println("April");
break;
case "5":
System.out.println("May");
break;
case "6":
System.out.println("June");
break;
case "7":
System.out.println("Jully");
break;
case "8":
System.out.println("August");
break;
case "9":
System.out.println("September");
break;
case "10":
System.out.println("October");
break;
case "11":
System.out.println("November");
break;
case "12":
System.out.println("December");
break;
default:
System.out.println("Invalid Month");
}

}
====================================================================
package FlowControlprograms;
//write a program to print numbers from 1 to 10 in a single row with one tab space.
public class Fc_Assignment10 {

public static void main(String[] args) {


for(int i=1;i<=10;i++)
{
System.out.print(i+"\t");
}

}
=======================================================================
package FlowControlprograms;
//write a program to print even numbers between 23 and 57 .Each number should be
printed in a separate row.
public class Fc_Assignment11 {

public static void main(String[] args) {


for(int i=23;i<=57;i++)
{
if(i%2==0)
System.out.println(i);
}

}
=============================================================================
package FlowControlprograms;
import java.util.Scanner;
//write a program to check the given number is prime or not
public class Fc_Assignment12 {

public static void main(String[] args) {


// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);

}
=================================================================================
package FlowControlprograms;

public class Fc_Assignment13 {


//write a program to print prime numbers between 10 and 59.

public static void main(String[] args) {


// TODO Auto-generated method stub
int flag;
for(int i=10;i<=99;i++) {
flag=1;
for(int j=2;j<=i/2;j++)
{
if(i%j==0)
{
flag=0;
break;
}
}
}
if(flag==1)
{

}
===============================================================
java Basics
======

public class Assignment1{

public static void main(String[] args) {


// TODO Auto-generated method string
System.out.println(args[0]+" Technologies "+args[1]);
}
}
===================================
public class Assignment2 {

public static void main(String[] args) {


// TODO Auto-generated method stub
System.out.println("Welcome "+args[0]);

}
========================================
public class Assignment3 {

public static void main(String[] args) {


// TODO Auto-generated method stub
int num1=Integer.parseInt(args[0]);
int num2=Integer.parseInt(args[1]);
int sum=num1+num2;
System.out.println("The Sum of "+num1+"+"+num2+"="+sum);

}
=============================================

You might also like