can't solve this assignment

I know it's a c++ community but can't find help anywhere else its a java assignment please help me


1-An airline company allows travelers to carry a specified weight. The program should calculate the ticket
price according to the added weight in kilogram (the weight should always be less than 70 kilos):
 If the weight is less than 30 kilos the System generates a new facture with 8% discount.
 If the weight is between 30 and 50, the system says “Pass”.
 Otherwise, the program generates the overloaded weight and he should pay $ 20 per kilo.
a) Define a double method called weightPrice that takes two integers as parameter; the weight and the
ticket price then it should returns the new ticket price according to the entered values.
b) Write a test program (main) that asks the user to enter the name, desired weight and the ticket price
of each traveler and displays the ticket price for each one by invoking (calling) the weightPrice
method.
Sample Run:
Enter the name of traveler: Rima
Enter the ticket price and the weight: $1053 52
Dear Rima you are overloaded by 2 kilo your new balance is:
$1093


2-We need to create a problem that states whether the lines are "parallel, perpendicular" the program asks
the user to enter reads the coordinates (x,y) for four points 1, 2, 3 and 4 then finds the slops ():
Hint:
 Two lines are parallel if they have the same slop.
 Two lines are perpendicular if the product of slops equals -1.

Sample Run:
Enter the coordinates (x,y) for point 1: 1 -1
Enter the coordinates (x,y) for point 2: 4 5
Enter the coordinates (x,y) for point 3: 3 2
Enter the coordinates (x,y) for point 4: 5 6

Slop of Line (AB) =2.0
Slop of Line (CD) = 2.0
Lines are paralle
I used this method

public static double weightoverticket (double ticket) {
double weight ;
ticket = ticket + weight ;
return ticket;
> I know it's a c++ community but can't find help anywhere else its a java assignment please help me
Really?
https://duckduckgo.com/?q=java+programming+help+forum&t=newext&atb=v296-1&ia=web
Whether it's Java, C++, or FORTRAN 77, nobody here wants to just have an assignment prompt shoved in their face with nothing else to show. If you tell us specifically what you're having trouble with, we're more likely to help you.

You didn't ask a question in your second post, but I assume that that function is giving you some error? You never assign a proper value to weight, so in Java this is initialized to 0 (in C++ it's undefined behavior, btw). So your function is essentially just doing return ticket;
Last edited on
yea you need something like this pseudo code:

if weight <= 30
ticket price *= 0.92; //8% discount. if using integers, how do you round (up or down?).
else if weight > 50
ticket price += (weight-50)*20;
else
return ticket price; //unchanged.

lots of ways to do 2. brute force is just rise/run (check for 0 run) which is also opposite over adjacent if you want to throw trig at it...
Registered users can post here. Sign in or register to post.