Math - Algebra 101 - Challenge

You are pretty close; b = 100/120, that is not 4/5 right?
Other than that, good job!

Ah, dangit! It’s funny - that same error got me when I was doing the handwritten part to work it all out, and here it is again! Argh!

Thanks for the catch Ms. Sparkle!

If b = 2 and t = 120, then m = 0+(2*100) = 240;
If m = 100 and t = 120, then b = (0-100)/(-120) = ~0,833

For Java Fans:

import java.util.Scanner;

public class Main {
	
	static void calculate_m() {
		float c = 0, b = 0, t = 0;
		float result;
		Scanner userInput = new Scanner(System.in);
		
		System.out.print("\nPlease enter the value of c (Current Fuel): ");
		try {
			c = userInput.nextInt();
		} catch(Exception e) {
			
		}
		
		System.out.print("\nPlease enter the value of b (Burn Rate): ");
		try {
			b = userInput.nextInt();
		} catch(Exception e) {
			
		}
		
		System.out.print("\nPlease enter the value of t (Time): ");
		try {
			t = userInput.nextInt();
		} catch(Exception e) {
		
		}
		
		result = c+b*t;
		System.out.printf("Result: %f%n%n", result);
		
	}
	
	static void calculate_b() {
		float c = 0, m = 0, t = 0;
		float result;
		Scanner userInput = new Scanner(System.in);
		
		System.out.print("\nPlease enter the value of c (Current Fuel): ");
		try {
			c = userInput.nextInt();
		} catch(Exception e) {
			
		}
		
		System.out.print("\nPlease enter the value of m (Maximum Fuel): ");
		try {
			m = userInput.nextInt();
		} catch(Exception e) {
			
		}
		
		System.out.print("\nPlease enter the value of t (Time): ");
		try {
			t = userInput.nextInt();
		} catch(Exception e) {
		
		}
		
		result = (m-c)/t;
		System.out.printf("Result: %f%n%n", result);
		
	}
	
	static void calculate_c() {
		float b = 0, m = 0, t = 0;
		float result;
		Scanner userInput = new Scanner(System.in);
		
		System.out.print("\nPlease enter the value of b (Burning Rate): ");
		try {
			b = userInput.nextInt();
		} catch(Exception e) {
			
		}
		
		System.out.print("\nPlease enter the value of m (Maximum Fuel): ");
		try {
			m = userInput.nextInt();
		} catch(Exception e) {
			
		}
		
		System.out.print("\nPlease enter the value of t (Time): ");
		try {
			t = userInput.nextInt();
		} catch(Exception e) {
		
		}
		
		result = m-(b*t);
		System.out.printf("Result: %f%n%n", result);
		
	}
	
	static void calculate_t() {
		float b = 0, m = 0, c = 0;
		float result;
		Scanner userInput = new Scanner(System.in);
		
		System.out.print("\nPlease enter the value of b (Burning Rate): ");
		try {
			b = userInput.nextInt();
		} catch(Exception e) {
			
		}
		
		System.out.print("\nPlease enter the value of m (Maximum Fuel): ");
		try {
			m = userInput.nextInt();
		} catch(Exception e) {
			
		}
		
		System.out.print("\nPlease enter the value of c (Current Fuel): ");
		try {
			c = userInput.nextInt();
		} catch(Exception e) {
		
		}
		
		result = (m-c)/ b; 
		System.out.printf("Result: %f%n%n", result);
		
	}

	public static void main(String[] args) {
	
		String input;
		Scanner userInput = new Scanner(System.in);
		
		while(true) {
		
			System.out.print("What do you want to calculate? (m, b, c, t)");
			
			try {
				input = userInput.next();
			} catch(Exception e) {
				System.err.println("Error! " + e);
				continue;
			}
			
			if(input.equals("m") || input.equals("M")) {
				calculate_m();
			}
			
			if(input.equals("b") || input.equals("B")) {
				calculate_b();
			}
			
			if(input.equals("c") || input.equals("C")) {
				calculate_c();
			}
			
			if(input.equals("t") || input.equals("T")) {
				calculate_t();
			}
		}
	}
}

Have a nice day :slight_smile:

1 Like

You’re welcome, keep up the good work!

Enjoy your day!

Here’s my solution

  1. Simple, but I couldn’t resolve it for longer time :confused:

c = m - (b * t)
c + b * t = m

Check

0 + 2 * 120 = 240(m)

  1. Harder, but not that much

c = m - (b * t)
c - m = - bt → both sides * -1
-c + m = bt → both sides * t
(-c + m) / t = b

Check

(-0 + 240) / 120 = 240/120 = 2(c)
Look ok for me

1 Like

[spoiler] For b=5:
m=600


For m=100:
b=0,833…

Is this correct? Had some issues but I am starting to get it now: [/spoiler]

1 Like

t = 120 c = 0

b = (m - c) / t
b = 0.8333333

m = c - (b * t);
m = 240

1 Like

I struggled with this one a bit so instead of wasting time trying to figure it out without a clue I looked at the answers others gave and spent time working backwards to figure out what the answer meant. I wasn’t going to give up on it until I fully understood and I think I got there.

So for m = ? we have the numbers for burn rate at 2 and time at 120 so if we look at the figures once the m = 0 (and c = 0) we can fill out the equation m = c - (b * t) so 0 = 0 - (2 * 120) = 240.

For b = ? we can also go to the end of the process, knowing that the m = 100, c = 0 and t = 120 we can populate the equation b = (m - c) / t so (100 - 0) / 120 = 0.83.

I haven’t explained it very well but it was important to me to understand the equations and hopefully understand algebra more moving forward.

In your explanation :

c = m - (b * t)
c - m = -bt ← Subtract m from both sides
(c - m) / -t = b ← Divide both sides by -t
b = (c - m) / -t ← Swap the sides to tidy everything up

Why is b on the 3rd line not a negative?

I ended up with the following:

m = c + bt

For the time of 0 and burn rate of 2, this is 240 needed for max fuel.

And for burn rate:

b = (c - m) / -t

For a time of 120 seconds, this means a burn rate of 0.8333 per second.

It was a fun exercise. The last one took me some double-checking as I had mistakenly tried to equate it to burn rate of 2 from the previous examples… but b is what we are looking for!

burn rate 0.833…

max fuel 240

Max fuel M=120
and burn rate b = 1

My Answers

t = (m - c) / b
120 = (120 - 0) / 1 or 120 = (240 - 0) / 2 and so forth

b = (m - c) / t
1 = (120 - 0) / 120 or 2 = (240 - 0) / 120 and so forth

I like how Martin_Castaneda wrote out his response.
I’ll have to try that in my notebook as well just for the extra practice!

1 Like

Privacy & Terms