Name:-Roll No: - Class:-: Badugula Rohan Reddy 20009 CSEA / Group-A
Name:-Roll No: - Class:-: Badugula Rohan Reddy 20009 CSEA / Group-A
Code:-
package com.company;
import java.util.Scanner;
public class Ass_1_1 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
double widgets,gizmo;
double total;
System.out.println("Enter the number of widgets : ");
widgets = sc.nextDouble();
System.out.println("Enter the number of gizmo : ");
gizmo = sc.nextDouble();
total = (75*widgets+112*gizmo)/1000;
System.out.println( total + " Kilograms!");
}
}
Output :-
Output :-
3)Physics : Acceleration.
Code:-
package com.company;
import java.util.Scanner;
public class Ass_1_3 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
double v0,v1,t,a;
v0 = sc.nextDouble();
v1 = sc.nextDouble();
t = sc.nextDouble();
a = ((v1 - v0)/t);
System.out.format("%.2f",a);
}
}
Output:-
4) Perimeter of Circle.
Code:-
package com.company;
import java.util.Scanner;
public class Ass_1_4 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
double radius,perimeter;
System.out.println("Enter the radius:");
radius = sc.nextInt();
perimeter = 2 * 3.14 * radius;
System.out.println("The perimeter is : "+
perimeter);
}
}
Output:-
Code:-
package com.company;
import java.util.Scanner;
public class Ass_1_5 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int num,sum = 0,i = 0;
System.out.println("Enter the number");
num = sc.nextInt();
while(num != 0)
{
i = num % 10;
sum = sum + i;
num = num / 10;
}
System.out.println("The sum of digits is :
"+sum);
}
}
Output:-
6) Units of Time.
Code:-
package com.company;
import java.util.Scanner;
public class Ass_1_6 {
public static void main(String[] args){
Scanner sc= new Scanner(System.in);
int days,hours,minutes,seconds,total;
days = sc.nextInt();
hours = sc.nextInt();
minutes = sc.nextInt();
seconds = sc.nextInt();
total =
days*86400+hours*3600+minutes*60+seconds;
System.out.format("The total Seconds for %d
days %d hours %d minutes and %d seconds is %d
seconds",days,hours,minutes,seconds,total);
}
}
Output:-
Code:-
package com.company;
import java.util.Scanner;
public class Ass_1_7 {
public static void main(String[] args){
Scanner sc =new Scanner(System.in);
double meal,tax,mealTax,tips,total;
meal = sc.nextDouble();
tax = meal*5 /100;
mealTax = meal + tax;
tips = meal*18 /100;
total = mealTax + tips;
System.out.printf("meal = %.2f \n",meal);
System.out.printf("tax = %.2f \n",tax);
System.out.printf("meal tax = %.2f\n",mealTax);
System.out.printf("tips = %.2f \n",tips);
System.out.printf("total cost = %.2f \n",total);
}
}
Output:-