Beruflich Dokumente
Kultur Dokumente
Metropolis or city
Let three variables be given containing information for a city:
boolean isCapitalCity;
int numberOfCitizens;
double taxPerCitizen;
with the following meaning:
i sCapitalCity is true if and only if the city is a capital city.
numberOfCitizens is the number of citizens in this city.
taxPerCitizen is the average tax per month a citizen of the city pays.
We define a city to be a Metropolis ,if it is either a capital city with more than 100
000 citizens or a normal city with more than 200 000 citizens and an average
income of 720 000 000 per year.
Return a boolean expression – true if the city is a metropolis.
6. Mathematical Expression
Find the answer for the expression: f(n)=sqr((n-1))+1 for a given n. Use both
recursive and iterative approach
Exercise 6: Arrays
1. Grade calculation
Write a program to store the marks in 4 subjects(English, Science, Maths,
Social, Arts) of 5 students. The program should have two functions to
To calculate the average marks for each subject
To calculate the total marks for each student.
Assume arrays of marks for each student in the predefined subject order(e.g {
<marks for English>, <marks for Science>,<marks for Maths>,<marks for
Social>,<marks for Arts>}
2. Stack Implementation – Chocolate box problem
You have a set chocolates of different makes (KitKat,Cadbury, Toblerone).
There is one box where all the chocolates need to be placed. Only one
chocolate can be placed inside the box at one instance and only one can be
retrieved at any instance. The chocolate which is placed last will be at the top
of the box while the chocolate which is place first will be at the bottom of the
box.
Write a program to insert a set of chocolates in the order in which is it
received (random) into a box (that can hold 10 chocolates) and retrieve
specific chocolates from the box.
3. Find second largest number
Write a program to find the second largest number in an array of unsorted
numbers. If there is no second largest number, return -1
4. Insert Strings
Write a program to insert Strings to an array of size 10. If the string is already
present in the array, return a message saying “<String>, already exist”. After
the 10th element, for any insert action, return a message “No more Strings
can be stored”.
5. Find occurrence of an integer
Write a program to find the count of a particular value in a array of integers.
6. Replace a string
Write a program to replace a particular string if it is there in an array of
strings.
7. Concatenate a string
Write a program to concatenate an array of string into a single string and
return the string.
8. Introduce a delimiter
Write a program to insert a delimter (e.g “$”) on every 3 rd position in an array
of strings.
9. Replace strings
Write a program to replace an array of alphabets (A – J) in upper case with
corresponding lower case alphabets.
Tarzan book store decided to go online to increase its’ revenues and provide its’ customers a way to
buy books through internet.
Tarzan maintains the list of books along with quantity. Administrator should be able to add books to
the inventory. Administrator will add books with book name, author name, category (Java, Philosophy,
Fiction, OS, self help etc.), price and quantity.
Anybody can log on to the website to browse through the books available in tarzan.com. It should have
a facility to search books by category or author name or book name and it should accept wild
characters also. Out of stock status needs to be displayed based on the quantity.
If anybody decides to buy a book online, he needs to give a customer id to do online transaction. If new
customer, he needs to register with tarzan.com by giving his personal details that are name, age, sex,
address and contact number.
Customer should have a facility to buy more than one book at one click. Customer can either choose to
buy a book or add it in his “my books” list. If he chooses to buy book/books, tarzan.com needs to get
the mode of payment (credit/debit card) and collect the card details. If customer chooses to add
book/books to “my books”, the list of selected book need to be added to his “my books” list.
Next time, when customer logs in, there should be an option to view “my books”. From there, option is
needed to buy the book. Also, customer needs to have an option to see his previously ordered books
with buy date.
Before starting coding of the above application in, please complete the following and get it reviewed.