These are the problems:
Ground Beef Value Calculator
Different packages of ground beef have different percentages of fat and different costs per pound. Write a program that asks the user for:
1. The price per pound of package "A"
2. The percent lean in package "A"
3. The price per pound of package "B"
4. The percent lean in package "B"
The program then calculates the cost per pound of lean (non-fat) beef for each package and writes out which is the best value.
Price per pound package A:
2.89
Percent lean package A:
85
Price per pound package B:
3.49
Percent lean package B:
93
Package A cost per pound of lean:3.4
Package B cost per pound of lean:3.752688
Package A is the best value
Assume that the two packages will not come out equal in value.

This is my unfinished code because I don't know how would I compute the formula to derived with these answers:

import java.util.Scanner;
public class DMExer5 {
    public static void main (String [] args){
    Scanner scan = new Scanner(System.in);
   
   System.out.println("Price per pound package A: ");
    double priceA = scan.nextDouble();
    System.out.println("Percent lean package A: ");
    double leanA = scan.nextDouble();
    System.out.println("Price per pound package B: ");
    double priceB = scan.nextDouble();
    System.out.println("Percent lean package B: ");
    double leanB = scan.nextDouble();
    
    double percentA = 100-leanA;                         // not sure with my formulas
    double percentB = 100-leanB;
    double A = priceA + (percentA*0.01);
    double B = priceB + (percentB*0.01);
    
    System.out.println("");
    System.out.printf("Package A cost per pound of lean: %.2f " , A);
    System.out.println("");
    System.out.printf("Package B cost per pound of lean:%.4f " , B);
    System.out.println("");
    
 if(A<B){
        System.out.println("package A is the best value");}
    
    else {
        System.out.println("package B is the best value");
        }
    }

  

}

Second, Write a program that asks a user for their birth year encoded as two digits (like "62") and for the current year, also encoded as two digits (like "99").
The program is to correctly write out the users age in years.
Sample Output:
Year of Birth: 62
Current year: 99
Your age: 37
The program will have to determine when a two digit value such as "62" corresponds to a year in the 20th century ("1962") or the 21st century.
Here another run of the program, where "00" is taken to mean the year 2000:
Year of Birth: 62
Current year: 00
Your age: 38
Assume that ages are not negative. Another run of the program:
Year of Birth: 27
Current year: 07
Your age: 80
In the following run, the age of the person could be 6 or 106 depending on the assumptions. Assume that the age will always be less than or equal to
100.
Year of Birth: 01
Current year: 07
Your age: 6
codes:

import java.util.Scanner;
public class DMExer5b {
    public static void main(String args []){
    Scanner scan = new Scanner(System.in);
   
    System.out.print("Year of Birth: ");
    int birth = scan.nextInt();
    System.out.print("Current Year: ");
    int current = scan.nextInt();

    int age = current-birth;

    if(current<20){  
        int lower = current + 2000;
        int age2 = lower - (birth+1900);
        System.out.println("Your age:"+age2);}
 
   else if (birth<20){
     int age3 = current - birth;
      System.out.println("Your age:" + age3); }
   else {
 
    System.out.println("Your age:" + age);}
   }
}

Thanks for the help!

In the first problem get rid of the percentA and the percentB.

Then replace this.

double A = priceA + (percentA*0.01);
double B = priceB + (percentB*0.01);

with this.

double A = priceA / leanA * 100;
double B = priceB / leanB * 100;

Otherwise your code is perfect for the first project the second however is a much larger problem.

You kneed to figure out the second one I will give you hints and such, but you will not learn to think critically with java if you don't figure most of this out on your own you are not going to get any better.

start with something simple like have the program solve for athe age of the person if it is given the entire year

here is a sample run:

Birth year:
1973
Current year:
2006
Your age: 33

Now that you have the basics move to solving for the current year based on the past year. Remember the years can not be greater than 100 so if they are added together without any mathematical changes and they are greater than 100 then you need to subtract them to get the age.

Next you need to deal with numbers that are after the date 1999 so 2000-2099. Since the user is entering a date like 01 or 08 assume that the birth date is before 2000 solve for the age then check whether it is less than or equal to 100 if so print it if not . . .

well I think you can figure it out from here.

Hey, Mr. DL7..thank you very much for your help. As a result, my codes are successfully executable.Thanks again. Your a big help. Hope you'll never get enough to help other students like me.

If you got the help you needed, please mark the thread as solved so that other people can reference it later and the other forum members know that their help isn't needed here anymore.

Your very welcome.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.