COMP 6481 Programming and problem solving Lab 2 solution

$30.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

2A Problem Description:
You are invigilating a high school level contest, so to ensure that no middle
school students try to sneak in and make older students feel uncomfortable, an
age gate is being considered.

Input Specification:
The first line contains N, 1 ≤ N ≤ 25, the number of students taking the exam.
Each of the next N lines contain 3 integers representing a person’s birth date, in
the format DD MM YYYY (separated by spaces).

Output Specification:
The output will comprise of N lines, each printing a decision about whether the
participant is at least 13 years old as of April 18, 2022 (18 04 2022) or not. The
message to be printed is either “old enough” or “too young” depending on the
participant’s age.

Sample Test Case:
Test Case Input Test Case Output
3
28 10 2007
27 02 2005
26 11 2009
old enough
old enough
too young

Note: No extra spaces, tabs, blank lines, punctuations, or any other superfluous
characters are allowed. You must use only one scanner in your code.

2B Problem Description:
“Snakes and ladders” is a very popular game. It uses a 10×10 maze, with cells
numbered from 1 to 100, and populated with snakes and ladders. A sample game
is shown in the figure below. Every player gets a chance to play and advance in
the maze, depending on the number they get on the six-sided dice when thrown.

The advancement is in the increasing order from 1 to 100. All players start from
cell numbered 1 and attempt to reach to cell numbered 100. The player who
reaches first to cell number 100, is the winner. If the game is stopped in between,
the player closest to cell 100 in number is the winner. Assume that both players
will never be on the same cell when the game is stopped.

If a player lands on a cell with a snake head,
then the player gets a penalty to retreat to tail
of the snake. If a player reaches foot of a
ladder, then the player climbs directly to the
top of the ladder. This is repeated if there
exists another snake (or ladder) at the new
cell. A cell will never have a mouth of a snake
and a foot of a ladder simultaneously.

Write a Java program to simulate the game for
a given number of moves. There will be two
players, named A and B, who throw the dice
alternately. Program should output the name
of the player at the highest position (closest to
100), along with the player’s cell number.

Input Specification:
 The first line of input will contain a single integer N.
 Next N lines each will contain a pair of integers. Each pair will describe either
a snake or ladder by its start cell and an end cell. For a snake, start cell will
be higher than end cell and vice versa for a ladder.

 Following line of input has a single integer D, indicating the number of moves
(dice throws) made by both players A and B.

 Last line contains D integers, each indicating a dice throw, alternately made
by A and B. First throw is made by player A. Each dice throw is an integer
between 1 and 6.

Output Specification:
Your program should output the name of the winner (A or B) followed by the
player’s position at the end of game, with a single space in between.

Sample Test Cases:
No Sample Input Sample Output
1
2
27 88
97 14
18
4 1 3 2 6 3 6 3 2 4 4 2 1 1 5 2 4 6
B 25
2
3
14 99
99 1
7 14
10
5 1 3 3 1 1 4 1 6 1
B 2