Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have asked to build booking holiday system and I have faced a problem with calculating the prices. I do not know how to find the price per room per either adult or child. The system requirements are as the following:
The system allows the user to enter the number of adults and/or children going on the holiday with children charged at half price. the cost per night per adult is 50. what is the equation to find the prices?
For example, if two adults with two children books two rooms for two nights?
So the user enters the number of adults and children into the system. Use variables A and C to represent the two respectively. If it is $50 per adult and $25 per child, you end up with the equation total cost = (50A + 25C)*number of nights.
So if two adults and two children book for two nights you get total cost = (50*2+25*2)*2 nights = $300.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have one scenario, where I have to update the record record, If the record is present in database with the effective and expire date splits logic.
For example the below record is already available in Database.
Item tax effectiveStartDate effectiveEndDate
1 5% 17-04-2017 31-12-2047
Now I want to update the record with the given effective start date and tax percentage.
For example I have given two dates with 6% of tax then I need to update the record if it is present. The following are the inputs:
effective start date: 17-04-2017;
effective end date: 31-12-2047`;
item : 1
tax : 6 %
Now record is already present, now what I want is , I have to adjust effective date and expire dates, 20-05-2017 and 31-12-2019.the output of should be like the following:
Item tax effectiveStartDate effectiveEndDate
1 5% 17-04-2017 19-05-2017
1 6% 20-05-2017 31-12-2047
If again I have given some other dates it should be adjusted like above. In my POC I am using spring MVC with JDBC template I am using. Can someone help me on this logic?
As I understand, if you get other tax value (10% f.e.) to Item 1, you will have to update all entries in the database, isn't it?
If that's the problem, try getting all of them in a List and doing something like:
//get all from DB
for(YourObject obj : List){
if(obj.effectiveFinalDate<newObject.effectiveStartDate){
obj.effectiveFinalDate = newObject.effectiveStartDate;
}
if(obj.effectiveStartDate>newObject.effectiveFinalDate){
obj.effectiveStartDate = newObject.effectiveFinalDate;
}
}
//persist all
I am not sure at all about what do you want exactly, but I guess it will be something similar to this
EDIT: if you want to set dates to a day more or less, look documentation, it depends on what Object you use as date
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I'm looking for an algorithm to combine two values;
Where the first value indicates a positive result when the value is higher. For example, 0.98 is 'good' and 0.15 is 'bad'.
Where the second value indicates a positive result when the value is lower. For example, 10,000 is 'bad', whereas 1000 is 'good'.
I need a method of determining a value that can represent both of these scales with one number, so that I can sort my findings on my application from high to low accordingly. I'm not sure if anyone knows of such an algorithm, or any advice, but any help is greatly appreciated. Thank you.
P.S. I am aware I can 'negate' one of the two values, to have them appear on a similar scale, however I'm not sure how this would work in Java.
EDIT: Sorry, so to elaborate, I'm sorting images based on similarity to a user input image. Each of my algorithms that I'm using to return a value of similarity, function on a different scale. The first being a value between 0.00 and 1.00, with numbers being closer to 1.00, indicating the image is more similar to the original. Whereas, my second algorithm returns values from 1000+, with higher values indicating the image is less similar to the original. I need to take these two values and combine them to allow me to sort the resulting images in order of similarity, with the most similar image being shown at the top of my list, and the least similar at the bottom. Hopefully this helps clear up any confusion. Thanks again.
If your only goal is sorting, you need to come up with a function g(x,y) that represents the "goodness" of your pair of values. A pair (x1,y1) is better than (x2,y2) if and only if g(x1,y1) > g(x2,y2).
The function must represent what you consider "good". A simple example would be:
g(x,y) = x - y / 10000
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I try solve some problem in the arena, but now I can not find it there. I just have a text of solution:
DEFINITION
Class Name: MatchMaker
Method Name: getBestMatches
Paramaters: String[], String, int
Returns: String[]
Method signature (be sure your method is public):
String[] getBestMatches(String[] members, String currentUser, int sf);
PROBLEM STATEMENT
A new online match making company needs some software to help find the “perfect
couples”. People who sign up answer a series of multiple-choice questions.
Then, when a member makes a “Get Best Mates” request, the software returns a
list of users whose gender matches the requested gender and whose answers to
the questions were equal to or greater than a similarity factor when compared
to the user’s answers.
Implement a class MatchMaker, which contains a method getBestMatches. The
method takes as parameters a String[] members, String currentUser, and an
int sf. Here members contains information about all the members. Elements of members are of the form
NAME G D X X X X X X X X X X
NAME represents the member’s name
G represents the gender of the current user.
D represents the requested gender of the potential mate.
Each X indicates the member’s answer to one of the multiple-choice
questions. The first X is the answer to the first question, the second is the
answer to the second question, et cetera.
currentUser is the name of the user who made the “Get Best Mates” request.
sf is an integer representing the similarity factor.
Can you help me, and tell how to find a solution in the TopCoder arena?
use the problem archive to find out which SRM or tournament the class was used in.
http://community.topcoder.com/tc?module=ProblemArchive
this will show you the top submissions from each of the acceptable programming languages. You can also use the summary button if you know which SRM the class is from but this does not guarantee that the solution you view is correct if the problem was an old one.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
So I'm making a simple game in java. In this game I want there to be an infinite number of players.
The game is Dictionary, but not the one where you race to find a word in a dictionary.
How to play:
A person chooses a word that no one would know.
Everyone enters a made up definition that is believable.
Each person guesses which one is the real definition.
You get a point for guessing correctly and for the number of people who guess your word
(Steps 2 and 3 are ignored by the person who chooses a word)
My program (So far):
Choose start or quit
When start is pressed the number of players selected (Not including word selector).
Word selector chooses word in JPasswordField
Enters definition in JPasswordField
The word is told to Player 1 and then they must enter a definition into a JPasswordField
Repeats step 5 until the times repeated are equal to the number of players.
The problem I'm having:
Player + numberrepeated = passwordfield.getText;
doesnt exist.
I need to have the variable change each time.
You can't have dynamic variable names in Java. What you can do is use a Map, to associate a key (the player's name, for example), with a value (the player's password, for example):
Map<String, String> passwordsByPlayer = new HashMap<>();
...
passwordsByPlayer.put(playerName, passwordField.getText());
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have java hashset like this
Java Hashset
7327896542976267 B ON 17 1381960719243
4116229919133022 B ON 7 1381960779618
2467710535609327 T OFF 5 1381960865253
7327896542976267 B OFF 16 1381961008020
7690519232957130 T ON 1 1381961124863
7690519232957130 T OFF 1 1381961364863
4144171091392103 F ON 1 1381961433257
2332355946816642 B ON 2 1381961601782
4270931484327447 B ON 10 1381961881239
6048000070479064 B ON 3 1381961959977
4270931484327447 B OFF 10 1381962121239
6056389598100654 T ON 13 1381962380866
5270503505599671 B ON 8 1381962381419
6048000070479064 B OFF 2 1381962588710
6056389598100654 T OFF 13 1381962620866
3873532220632004 T ON 1 1381962807491
3873532220632004 T OFF 1 1381963047491
3495435380122245 B ON 10 1381963314807
3495435380122245 B OFF 10 1381963554807 ................
Explanation -
This is information about passenger travelling of a public transport system,
3495435380122245(card number) B(transport type) ON(start travelling) 10 (travelling zone) 1381963314807 (time)
3495435380122245(card number) B(transport type) OFF(finish travelling) 15 (travelling zone) 1381963314807 (time)
QUESTION
This hashset has multiple entries for each passenger card number,
As a example, in above explanation that person travel 5 zones. How can I calculate this for each passenger? And how can I make a new hashset with new calculated values?
Working with objects will make your life much easier. For example a Trip object can hold information like card number, transport type, start time, finish time, start zone, finish zone, zone difference etc.
It will take one pass to your hashset to create another collection of such Trip objects. This collection can be a map (with card number as keys and Trip as values) if you want to search trips using card numbers later.
You need to sort the entries by time and replay them to build a state for each customer. With each event you add any charges incurred and at the end you know how much each customer's fee were.
BTW You can't sort a HashSet but you can sort an array or ArrayList.