Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

how do you create a javadoc for this program. public static void main(String[] a

ID: 3914646 • Letter: H

Question

how do you create a javadoc for this program.

public static void main(String[] args){
     Recipe r = createNewRecipe();
     r.printRecipe();
}

public static Receipe createNewRecipe() {
double totalRecipeCalories = 0;
        ArrayList <String> recipeIngredients = new ArrayList();
        boolean addMoreIngredients = true;
        String reply="";
        Scanner scnr = new Scanner(System.in);
        System.out.println("Please enter the recipe name: ");
        String recipeName = scnr.nextLine();
        System.out.println("Please enter the number of servings: ");
        int servings = scnr.nextInt();
    
        do {
            System.out.println("Please enter the ingredient name or type end if you are finished entering ingredients: ");
            String ingredientName = scnr.next();
            if (ingredientName.toLowerCase().equals("end")) {
                addMoreIngredients = false;
            } else {
                //recipeIngredients.add(ingredientName);
                System.out.println("Please enter the ingredient amount: ");
                float ingredientAmount = scnr.nextFloat();
                System.out.println("Please enter the measurement type (grams/spoons/ml): ");
                String type = scnr.next();
                System.out.println("Please enter the ingredient Calories: ");
                int ingredientCalories = scnr.nextInt();
                totalRecipeCalories = ingredientCalories * ingredientAmount;
                Ingredient d = new Ingredient(ingredientName, ingredientAmount, type,ingredientCalories);
                recipeIngredients.add(d)
                System.out.println("Do you want to continue. Y/N");
                reply = scnr.nextLine();
            }
        } while (!reply.equals("n")) ;
        scnr.close();
        Recipe recipe1 = new Recipe(recipeName, servings, recipeIngredients, totalRecipeCalories);
        return recipe1;
}
2
class Ingredient{
    private:
       String name;
       float amount;
       int calories;
       String measurementType;
    public:
       Ingredient(String s, float a, String t, int c){
           name = s;
           amount = a;
           calories = c;
           measurementType = t;
       }
       String getName(){
          return name;
       }
       float getAmount(){
          return amount;
       }
       int getCalories(){
          return calories;
       }
       String getMeasurementType(){
          return measurementType;
       }
}
public class Recipe {
    private String recipeName;
    private int serving;
    private ArrayList<Ingredient>recipeIngredients;
    private double totalRecipeCalories;
    ......
3
public void printRecipe() {
        int singleServingCalories = (int) totalRecipeCalories / serving;
        System.out.println("Recipe:" + recipeName + " Serves: " + serving + " Ingredients: ");
    
        for (int i = 0; i < recipeIngredients.size(); i++) {
            System.out.print(recipeIngredients.get(i).getName() + " ");
            System.out.print(recipeIngredients.get(i).getAmount() + " ");
            System.out.print(recipeIngredients.get(i).getMeasurementType() + " ");
            System.out.println(recipeIngredients.get(i).getCalories());
        }
        System.out.print(".Each serving has " + singleServingCalories + " calories");
    }
4
public void printRecipeWithDifferentServings(int n){
       int singleServingCalories = (int) totalRecipeCalories / serving;
     
     
       for (int i = 0; i < recipeIngredients.size(); i++) {
            float diffamount = recipeIngredients.get(i).getAmount()*((float)n/(float)serving);
            System.out.print(recipeIngredients.get(i).getName() + " ");
            System.out.print(diffamount + " ");
            System.out.print(recipeIngredients.get(i).getMeasurementType() + " ");
            System.out.println(recipeIngredients.get(i).getCalories());
       }
       System.out.print(".Each serving has " + singleServingCalories + " calories");  
}

Explanation / Answer

Steps to create java doc for a java program:

Command prompt

1-Before proceed further on this method, make sure

you have JAVA_HOME set on your computer environmental variable settings

you have completed your java project and its compiling perfectly

2-Open command prompt and go to the location where the files are located.

3-execute command javadoc -d <destination> <path_to_src>*.java

the Java doc files will be generated and placed in the same location from where the command is executed

==================