1) Write a program that helps solve the following problem: ground coffee from brand A costs Rs 45 for 450 grams, while ground coffee from brand B costs Rs 47 for 500 grams. Which brand is cheaper? Create Brand class. Suggest attributes and methods that are relevant for this problem.
1) Imagine you need to open a standard combination dial lock but don't know the combination and don't have a pair of bolt cutters. Write a program that prints all possible combinations so you can print them on a piece of paper and check off each one as you try it. Assume the numbers on the dial range from zero to thirty-six and three numbers in sequence are needed to open the lock.
Suppose the lock isn't a very good one and any number that's no more than one away from the correct number will also work. In other words if the combination is 17-6-32 then 18-5-31 will also open the lock. Write a program that prints the minimum number of combinations you need to try to guarantee opening the lock.
Compose an Employee class with the attributes personalia(data type Person),
employeeNo, yearofAppointment, monthSalary, and taxPercent. In addition to get
methods for all the attributes, the following operations should be available :
a. Find the employee’s monthly tax.
b. Find the gross annual salary
c. Find tax savings per year. To our employees June is tax free, and in
December there’s only half the usual tax.
d. Find name (in the format last name, first name.)
e. Find age
f. Find number of years employed at the company.
g. Find out if the person has been employed for more than a given number of
years (parameter)
h. Set methods to change attributes that it makes sense to change.
i. Find out in which cases an instance of the Employee class has to
collaborate with its personalia object in order to complete these tasks.
Write a simple program that puts data into an instance of the Employee class and calls all
the methods you’ve created. Check that the results are correct
Compose an Employee class with the attributes personalia(data type Person),
employeeNo, yearofAppointment, monthSalary, and taxPercent. In addition to get
methods for all the attributes, the following operations should be available :
a. Find the employee’s monthly tax.
b. Find the gross annual salary
c. Find tax savings per year. To our employees June is tax free, and in
December there’s only half the usual tax.
d. Find name (in the format last name, first name.)
e. Find age
f. Find number of years employed at the company.
g. Find out if the person has been employed for more than a given number of
years (parameter)
h. Set methods to change attributes that it makes sense to change.
i. Find out in which cases an instance of the Employee class has to
collaborate with its personalia object in order to complete these tasks.
Draw sequence diagrams for these operations.
An online E-commerce website is using non-persistent cookies to store the sessions of its visitors. The sessions are currently stored on the user’s computer locally. The website is facing a severe issue that before placing the order if the light goes off, the user’s cart information gets lost and the user has to add products again to the cart.
You are given a task to save the information stored in a session if the user accidentally leaves the website due to any reason. You have to select one session tracking technique from the following to resolve this issue.
1. URL Rewriting
2. HTTP Session
Now which technique you will prefer to resolve this issue. Justify your answer with solid arguments.
Use a single subscripted array to solve the following problem. Read in 20
numbers, each which is between 10 and 100, inclusive. As each number is read,
print it only if it is not a duplicate of a number already read. Provide for the
“worst” case in which all 20 numbers are different. Use the smallest possible way
to solve the problem.
List=[1,2,2,3,4,5]
Using break or continue condition find frequency of each element in List without using any other functions like append, count or dictionaries.
Swap Letters
Input: Python is a programming language
output: Python is e progremming lenguega
import java.util.*;
class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a String: ");
String line = in.nextLine();
boolean space = true;
boolean first = false;
for (Character letter : line.toCharArray()) {
if (letter == ' ') {
System.out.print(letter);
space = !space;
first = false;
} else if (space) {
if (!first) {
System.out.print(letter + ".");
first = true;
}
} else {
System.out.print(letter);
}
}
System.out.println();
in.close();
}
}
Do this coding without using array, split, Character letter, line.toCharArray, boolean
A palindrome is a string that reads the same forwards as backwards. Using only a fixed number of stacks and queues, the stack and queue ADT functions, and a fixed number of int and char variables, write an algorithm to determine if a string is a palindrome. Assume that the string is read from standard input one character at a time. The algorithm should output true or false as appropriate.