Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Lab2
- // first
- class first{
- public static void main(String args[]){
- int a=55;
- double b=7.896;
- double sum=a+b;
- System.out.println(sum);
- }
- }
- // second
- class second{
- public static void main(String args[]){
- long length=34567, breadth=76543;
- long area=length*breadth;
- System.out.println(area);
- }
- }
- // third
- class third{
- public static void main(String args[]){
- char ch='A';
- for (int i=0; i<26; i++){
- int num=ch;
- System.out.println("The ASCII value of " + ch + " is " + num);
- ch++;
- }
- char ch2='a';
- for (int i=0; i<26; i++){
- int num2=ch2;
- System.out.println("The ASCII value of " + ch2 + " is " + num2);
- ch2++;
- }
- }
- }
- // fourth
- class fourth{
- public static void main(String args[]){
- double d=3.5678;
- int num=(int)d;
- System.out.println(num);
- }
- }
- // fifth
- class fifth{
- public static void main(String args[]){
- int num1='F', num2='Q';
- int difference=num2-num1-1;
- System.out.println(difference);
- }
- }
- // sixth
- class sixth{
- public static void main(String args[]){
- int num=7;
- for (int i=1; i<=10; i++){
- System.out.println(num*i);
- }
- }
- }
- // seventh
- class seventh{
- public static void main(String args[]){
- int num=1;
- for (int i=1; i<=5; i++){
- num*=7;
- }
- System.out.println(num);
- }
- }
- // eighth (a)
- class eighthparta{
- public static void main(String args[]){
- for (int i=1; i<=6; i++){
- for (int j=1; j<=i; j++){
- System.out.print("*");
- }
- System.out.println();
- }
- }
- }
- // eighth (b)
- class eighthpartb{
- public static void main(String args[]){
- for (int i=1; i<=5; i++){
- for (int j=1; j<=5-i; j++){
- System.out.print(" ");
- }
- for (int k=1; k<=i; k++){
- System.out.print("* ");
- }
- System.out.println();
- }
- }
- }
- // ninth
- import java.util.*;
- class ninth{
- public static void main(String args[]){
- int a[]=new int[5];
- a[0]=6;
- a[1]=9;
- a[2]=4;
- a[3]=2;
- a[4]=0;
- int sum=0;
- for (int i=0; i<5; i++){
- sum+=a[i];
- }
- System.out.println(sum);
- }
- }
- // ninth (modified)
- import java.util.*;
- class ninth{
- public static void main(String args[]){
- int a[]=new int[5];
- Scanner sc=new Scanner(System.in);
- for (int i=0; i<5; i++){
- a[i]=sc.nextInt();
- }
- int sum=0;
- for (int i=0; i<5; i++){
- sum+=a[i];
- }
- System.out.println(sum);
- }
- }
- // tenth
- import java.util.*;
- class tenth{
- public static void main(String args[]){
- int a[][]=new int[3][4], b[][]=new int[4][3];
- a[0][0]=6; a[0][1]=9; a[0][2]=6; a[0][3]=9;
- a[1][0]=4; a[1][1]=2; a[1][2]=0; a[1][3]=420;
- a[2][0]=69; a[2][1]=4; a[2][2]=2; a[2][3]=0;
- b[0][0]=4; b[0][1]=2; b[0][2]=0;
- b[1][0]=6; b[1][1]=9; b[1][2]=9;
- b[2][0]=4; b[2][1]=2; b[2][2]=0;
- b[3][0]=6; b[3][1]=9; b[3][2]=6;
- int c[][]=new int[3][3];
- for (int i=0; i<3; i++){
- for (int j=0; j<3; j++){
- c[i][j]=a[i][0]*b[0][j]+a[i][1]*b[1][j]+a[i][2]*b[2][j]+a[i][3]*b[3][j];
- }
- }
- for (int i=0; i<3; i++){
- for (int j=0; j<3; j++){
- System.out.print(c[i][j] + " ");
- }
- System.out.println();
- }
- }
- }
- // tenth (modified)
- import java.util.*;
- class tenth{
- public static void main(String args[]){
- int a[][]=new int[3][4], b[][]=new int[4][3];
- Scanner sc = new Scanner(System.in);
- for (int i=0; i<3; i++){
- for (int j=0; j<4; j++){
- a[i][j]=sc.nextInt();
- }
- }
- for (int i=0; i<4; i++){
- for (int j=0; j<3; j++){
- b[i][j]=sc.nextInt();
- }
- }
- int c[][]=new int[3][3];
- for (int i=0; i<3; i++){
- for (int j=0; j<3; j++){
- c[i][j]=a[i][0]*b[0][j]+a[i][1]*b[1][j]+a[i][2]*b[2][j]+a[i][3]*b[3][j];
- }
- }
- for (int i=0; i<3; i++){
- for (int j=0; j<3; j++){
- System.out.print(c[i][j] + " ");
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement