Professional Documents
Culture Documents
FAL (2019-20) CSE1004 ETH G17-AB2 AP2019201000442 Reference Material II CAT1 Model Question Paper
FAL (2019-20) CSE1004 ETH G17-AB2 AP2019201000442 Reference Material II CAT1 Model Question Paper
Programme : B.Tech
Course Title : Problem Solving Using Java Code : CSE1004
Time : Max. :
01:30 Hours 50
Marks
Part A- Answer all the Questions (5 x 10= 50 marks)
1. Here's a Snakes and ladders board game to play with your friends and family.
How to play:
Each player puts their counter on the space that says 'start here'.
10
Take it in turns to roll the dice. Move your counter forward the number of
spaces shown on the dice.
If your counter lands at the bottom of a ladder, you can move up to the top
of the ladder.
If your counter lands on the head of a snake, you must slide down to the
bottom of the snake.
The first player to get to the space that says 'home' is the winner.
import java.util.*;
class Tirumala
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the month of Visit");
int m=sc.nextInt();
System.out.println("Enter the number of Adult");
int a=sc.nextInt();
System.out.println("Enter the number of Child");
int c=sc.nextInt();
double price;
if(m>=1 && m<=3 )
{
price=a*1000+c*750 -((a*1000+c*750)*0.1);
System.out.printf("Total Booking Price is Rs. %.2f",price );
}
}
}
Note :
It is also possible to solve using switch case.
5. Write a java program to get the following inputs from the student and calculate
the cut-off mark. Get the following inputs from user,
Student Name
Counselling Code
State
Get the Maths, Physic and Chemistry marks
Cut –off = ((Maths+Physics+Chemistry)/ 300)*100
Print the cut-off mark with 2 decimal points (eg. 75.25)
10
Expected Output
Answer :
import java.util.*;
class Student
{
public static void main(String args[])
{
System.out.println("Enter Student Register Number");
Scanner sc=new Scanner(System.in);
int regno=sc.nextInt();
System.out.println("Enter Counselling ID");
int id=sc.nextInt();
System.out.println("Enter Employee State");
String str2=sc.next();
System.out.println("Enter maths mark");
int m=sc.nextInt();
System.out.println("Enter physics mark");
int p=sc.nextInt();
System.out.println("Enter chemistry mark");
int c=sc.nextInt();
double cutoff=((m+p+c)/300)*100;
System.out.println("Student Register Number:"+regno);
System.out.println("Counselling ID:"+id);
System.out.println("State:"+str2);
System.out.println("Maths Mark:"+m);
System.out.println("Physics Mark:"+p);
System.out.println("Chemistry Mark:"+c);
System.out.println("Cut-off Mark:"+cutoff);
}
}