zafienas / SSK3100-G14

0 stars 0 forks source link

4) Percentage of Calories #7

Closed zafienas closed 4 years ago

zafienas commented 4 years ago

Problem Definition:

Draw a flowchart and write an algorithm that task the user to enter the numbers of calories and fat grams in a food item. Display the percentage of the calories that come from the fat. One gram fat has 9 calories, therefore:

Calories from fat = fat grams x 9

The percentage of calories from fat can be calculated as follows:

Calories from fat / total calories

If the calories from fat are less than 30 percent of the calories of the food, it should also display a message indicating the food is low in fat.

Submission:

  1. Flowchart
  2. Java source code
  3. Screenshot of the output
shazmi10 commented 4 years ago
//Developer : Muhammad Shazmi Bin Mohd Basri
//Task : Calculate the fat, calories and calories's from fat percentage

public class Calories {
    public static void main (String [] args) {
        double fat_gram = 10;
        double total_calories = 100;
        double calories = 0;
        double percentage = 0.0;
        String msg = "The food is low on fat";

        System.out.println("Fat gram =" +fat_gram);
        System.out.println("Total calories =" +total_calories);

        calories = fat_gram * 9;
        percentage = (calories / total_calories) * 100;

        System.out.println("The percentage of calories from fat =" + percentage);

        if (percentage < 30)
            System.out.println(msg);
        else
            System.out.println("The food is high on fat");
    }
}

image image

elyamaisarah commented 4 years ago
//Developer: Elya Maisarah (202487)
//Display the percentage of the calories that come from the fat.

public class Calories {
    public static void main (String [] args){

        double calories, fat_gram, total_calories, percentage;

        fat_gram = 3.2;
        total_calories = 100.0;
        String message = " The food is low in fat ";

         System.out.println(" Fat Grams = " + fat_gram);
         System.out.println(" Total calories = " + total_calories);

         calories = fat_gram * 9;
         percentage = (calories / total_calories) * 100;

         System.out.println(" The percentage of the calories from fat = " + percentage);

         if (percentage < 30)
             System.out.println(message);
         else
             System.out.println(" The food is high in fat ");

    }

}

calories flowchart 4

FtyRzd commented 4 years ago
//Developer : Siti Nurfatihah bt Rozaidi
//Task : Calculate the fat, calories and percentage of calories from fat

public class LabQuestionCalories {
    public static void main (String [] args){

        double fat_grams = 10.0;
        double total_calories = 100;
        double calories;
        double percentage;
        String msg = " The food is low in fat" ;

        System.out.println(" Fat grams = " + fat_grams);
        System.out.println(" Total calories = " + total_calories);

        calories = fat_grams * 9;
        percentage = (calories / total_calories) * 100 ;

        System.out.println( " The percentage of calories from fat = " + percentage);

        if (percentage < 30)
            System.out.println(msg);
        else
            System.out.println(" The food is high in fat");

    }
}

image image

Farhanazul98 commented 4 years ago
//Developer: Farhana Zulkhairi
//Task: Calculate the number of calories

public class Calories {
    public static void main (String [] args){

        double fat_gram = 3;
        double total_calories = 100;
        double calories;
        double percentage;
        String msg = "The food is low in fat";

        System.out.println("Fat Grams = " + fat_gram);
        System.out.println("Total Calories = " + total_calories);

        calories =fat_gram * 9;
        percentage = (calories / total_calories) * 100;

        System.out.println("The percentage of Calories from fat = " + percentage);

        if (percentage < 30)
            System.out.println(msg);
    }
}

image

image

Masturah29 commented 4 years ago
// Developer : Masturah Binti Mokhtar
// Task : Percentage of Calories

public class Calories {
    public static void main(String[] args) {

        double fat_gram = 3.25;
        double total_calories = 90;
        double calories = fat_gram * 9;
        double percentage = (calories / total_calories) * 100;

        System.out.println( " fat_gram  = " +3.25);
        System.out.println( " total_calories  = " +90);
        System.out.println( "calories_from_fat = " + calories);

        String msg = " The food is high in fat";

        System.out.println( " percentage of calories in fat = " + percentage );

        if (percentage > 30)
            System.out.println(msg);
        else
            System.out.println(" The food is low in fat ");
    }
}

calory

Calories picccc

NoorHusna202271 commented 4 years ago
//Diveloper: Noor Husna
//Task: indicating the food is low in fat.
public class activities4 {
    public static void main (String [] args){

        double fat_grams= 5;
        double total_calories= 150;
        double calories= 0.0;
        double percentage;
        String msg = "The food is low in fat";

        System.out.println("fat grams=" +fat_grams);
        System.out.println("Total Calories =" + total_calories);

        calories = fat_grams * 9 ;
        percentage = (calories/total_calories) *100;
        System.out.println("Calories form food =" + calories);
        System.out.println("The percentage of from fat=" +percentage);

        if (percentage < 30);
        System.out.println(msg);

    }
}

image image

haswani203024 commented 4 years ago
//developer = Nurul haswani Bt Ariffin
//Task: Calculate fat and calories

public class calories {
    public static void main  (String [] args)
    {
        double fat_gram = 10;
        double total_calories = 100;
        double calories = 0;
        double percentage = 0;
        String msg = "The food is low in fat";

        System.out.println("Fat Grams = " + fat_gram);
        System.out.println("Total Calories = " +total_calories);

        calories = fat_gram * 9;
        percentage =(calories / total_calories) * 100;

        System.out.println("The percentage of calories from fat = " + percentage);

        if (percentage < 30)
            System.out.println(msg);
        else
            System.out.println("The food is high on fat");

    }

}

image

image

fakhiraadriana commented 4 years ago
//Developer: Nur Fakhira Adriana
// Task    : To display the percentage of calories from fat

public class Calories {
    public static void main ( String [] args ) {
        double fat_grams = 2.8 ;
        double total_calories = 100.0 ;
        double calories ;
        double percentage ;
        String msg = " The food is in low fat ";

        calories = fat_grams * 9 ;
        percentage = (calories / total_calories) * 100 ;

        System.out.println( " Fat grams = " + fat_grams);
        System.out.println( "Total calories = " + total_calories);
        System.out.println("The percentage of calories from fat = " + percentage);

        if
        (percentage < 30 )
            System.out.println(msg);

        else
            System.out.println("The food is in high fat ");

    }
}

Screenshot (64)

Screenshot (65)

FarhanaYusri commented 4 years ago
// Developer : Farhana Yusri
// Task : Calculate percentage of calories

public class Main {

    public static void main (String [] args) {

            double fat_grams= 5;
            double total_calories= 100;
            double calories= 0.0;
            double percentage;
            String msg = "The food is low in fat";

        fat_grams = 5;
        total_calories = 100;
        String message = " The food is low in fat ";

        System.out.println(" Fat Grams = " + fat_grams);
        System.out.println(" Total calories = " + total_calories);

        calories = fat_grams * 9;
        percentage = (calories / total_calories) * 100;

        System.out.println(" The percentage of the calories from fat = " + percentage);

        if (percentage < 30)
            System.out.println(msg);
        else
            System.out.println(" The food is high in fat ");

    }

}

flowchart 4

4

nadiahisml commented 4 years ago

image

//Developer: Nadiah Ismail
//Task: Calculate percentage of calories from fat

public class Calories {
    public static void main(String[] args)
    {
        double fat_gram = 3;
        double total_calories = 100;
        double calories;
        double percentage;
        String msg = "The food is low in fat";

        System.out.println("Fat grams = " + fat_gram);
        System.out.println("Total calories = " + total_calories);

        calories = fat_gram * 9;
        percentage = (calories / total_calories) * 100;

        System.out.println("The percentage of calories from fat = " + percentage);

        if(percentage < 30)
            System.out.println(msg);
    }
}

image

WanNurfarah commented 4 years ago
// Developer: Wan Nurfarah Binti Wan Zulkifli
// Task: Percentage of Calories
public class Calories {
    public static void main (String [] args) {

        double fat_grams = 2;
        double total_calories = 100;
        double calories = 0;
        double percentage = 0.0;
        String msg = "The food is low in fat";

        System.out.println("Fat Grams = " + fat_grams);
        System.out.println("Total Calories = " + total_calories);

        calories = fat_grams* 9;
        percentage = (calories / total_calories) * 100;

        System.out.println("The Percentage of Calories From Fat = " + percentage);

        if (percentage < 30)
            System.out.println(msg);
    }
}
Screenshot (20)

flowchart calories

DenzKaizer commented 4 years ago
//Developer : Danish
//Task : Calculate Percentage of Calories

public class Main {

    public static void main(String[] args) {

        double fat_gram = 2.5;
        double total_calories = 90;
        double calories = fat_gram * 9;
        double percentage = (calories / total_calories) * 100;

        System.out.println("fat_gram = " + 2.5);
        System.out.println(" total_calories = " + 90);
        System.out.println(" calories_from_fat =" + calories);

        String msg = " The food is high in fat";

        System.out.println(" The percentage of calories in fat =" + percentage );

        if (percentage > 30)
            System.out.println(msg);
        else
            System.out.println("The food is low in fat");
    }
}

Percentage of fats

Soalan 4

azeelahyasmin00 commented 4 years ago
// Developer : Azeelah Yasmin Bt Azlee
//Task : Percentage of calories

public class calories {
    public static void main(String [] args)  {

     double fat_gram = 6;
     double total_calories = 100;
     double calories;
     double percentage;
     String msg = "The food is low in fat";

     System.out.println(" Fat Gram = "+fat_gram);
     System.out.println(" Total Calories = "+total_calories);

     calories = fat_gram * 9;
     percentage = (calories / total_calories) *100;

     System.out.println(" The percentage of calories from fat = " + percentage );

     if (percentage  < 30)
         System.out.print(msg);
     else
         System.out.println(" The food is high in fat");

    }
}

image

image

SorfinaNorly commented 4 years ago

Calories Flowchart


//Developer : Norshasha Sorfina
//Task : Percentage of Calories
public class CaloriesPercentage {
    public static void main(String[] args){

        double fat_gram = 5;
        double total_calories = 100;
        double calories;
        double percentage;
        String msg = " The food is low in fat ";

        System.out.println(" Fat Grams = " + fat_gram);
        System.out.println(" Total Calories = " + total_calories);

        calories = fat_gram * 9;
        percentage = (calories / total_calories) * 100;

        System.out.println(" The percentage of calories from fat = " + percentage);

        if (percentage < 30)
        System.out.println(msg);
        else
            System.out.println(" The food is high in fat");

    }

}

Calories Output

nrhzrhrsli commented 4 years ago

//Developer : Hazirah Rosli
//Task : Percentage of the calories

public class Percentage {
    public static void main (String [] args) {

        double fat_grams = 10 ;
        double total_calories = 100;
        double calories = 0;
        double percentage = 0.0;
        String msg = "The food is low in fat";

        System.out.println("Fat Grams = " + fat_grams);
        System.out.println("Total Calories = " + total_calories);

        calories = fat_grams * 9;
        percentage = (calories / total_calories) * 100;

        System.out.println("The percentage of calories from fat =" + percentage);

        if (percentage < 30)
            System.out.println(msg);

    }
}

image

image

NurHanisHaziqah commented 4 years ago
//Developer: Nur hanis haziqah binti hisham haizad
//calculate percentage of calories
public class Calories {
    public static void main ( String [] args){
        double fat_gram = 4;
        double total_calories = 150;
        double calories;
        double calories_percentage;
        String msg = " The food is in low fat";

        System.out.println(" Fat grams = " +fat_gram);
        System.out.println(" Total Calories = " +total_calories);

        calories = fat_gram * 9;
        System.out.println(" Calories from fat gram = "+ calories);

        calories_percentage = (calories/total_calories) * 100;
        System.out.println(" Percentage of calories = " + calories_percentage);

        if (calories_percentage < 30)
           System.out.println(msg);
        else
            System.out.println(" The food is in high fat");

    }
}

image Calories

Syazimah06 commented 4 years ago
//Developer : Siti Nur Syazimah Binti Abu
//Task : Percentage of the Calories

public class Calories {
    public static void main (String [] args) {
        double fat_gram = 10;
        double total_calories = 100;
        double calories = 0;
        double percentage = 0.0;

        String msg = "The food is low in fat";
        System.out.println("Fat Grams = " + fat_gram);
        System.out.println("Total calories = " + total_calories);

        calories = fat_gram * 9;
        percentage = calories / total_calories;

        System.out.println("The percentage of calories from fat = " + percentage);
        if (percentage < 30);
        System.out.println(msg);
    }
}

Calories1 calories

Lyanaazwanis99 commented 4 years ago
//Developer:Lyana Azwanis
//Task:Percentage of calories
public class Activity4 {
    public static void main (String [] args){
        double fat_grams = 4;
        double number_of_calories = 200;
        double calories = 0;
        double percentage = 0;
        String msg = "the food is low in fat";
        System.out.println("fat grams =" + fat_grams);
        System.out.println("total of calories =" + number_of_calories);
        calories = fat_grams * 9;
        percentage = calories/ number_of_calories * 100;
        System.out.println("calories from fat =" + calories);
        System.out.println("the percentage of fat=" + percentage);
        if (percentage < 30);
        System.out.println(msg);

    }
}

https://prnt.sc/ve2ncb


https://prnt.sc/ve2oai
AzimArifin commented 4 years ago

// Developer: Azim
// Task: Calculate fat and calories

public class Calories {
    public static void main (String [] args) {
        double fat_gram = 10;
        double total_calories = 100;
        double calories = 0;
        double percentage = 0.0;
        String msg = "The food is low on fat";

        System.out.println("Fat gram =" +fat_gram);
        System.out.println("Total calories =" +total_calories);

        calories = fat_gram * 9;
        percentage = (calories / total_calories) * 100;

        System.out.println("The percentage of calories from fat =" + percentage);

        if (percentage < 30)
            System.out.println(msg);
        else
            System.out.println("The food is high in fat");
    }
}
AzimArifin commented 4 years ago

Screenshot 2020-11-05 224633 Screenshot 2020-11-05 224727

ajim1619 commented 4 years ago

//Developer: Abdul Azim (203198)
//Task: Calories

public class calories {
    public static void main (String [] args) {
        double fat_gram = 3.3;
        double total_calories = 100;
        double calories = 0;
        double percentage = 0.0;
        String msg = "This food is low on fat";

        System.out.println("Fat gram =" +fat_gram);
        System.out.println("Total calories =" +total_calories);

        calories = fat_gram * 9;
        percentage = (calories / total_calories) * 100;

        System.out.println("The percentage of calories from fat =" + percentage);

        if (percentage < 30)
            System.out.println(msg);
        else
            System.out.println("The food is high on fat");
    }
}

Calories with flowchart Flowchart Calories

ikmalhafiq commented 4 years ago

flowchart 4

Screenshot 2020-11-06 002324


```java

//Developer : Ikmal Hafiq
//Task : Number of Calories

public class calories {
    public static void main (String[] args) {

        double fatgram = 10;
        double totalcalories = 100;
        double calories;
        double percentage;
        String msg = "The food is low in fat";

        System.out.println("Fat Grams = "+fatgram);
        System.out.println("Total Calories = "+totalcalories);

        calories = fatgram * 9;
        percentage = (calories / totalcalories) * 100;

        System.out.println("The percentage of calories from fat = "+percentage);

        if (percentage <30 )
            System.out.println(msg);

    }
}
izzatisyahzanani16 commented 4 years ago

Calories


// Developer : Izzati Syahzanani
// Task : Calculating Percentage of Calories

public class Calories {
    public static void main (String [] args){

        double fat_gram = 2;
        double total_calories = 100;
        double calories = 0;
        double percentage = 0.0;
        String msg = "The food is low in fat ";

        System.out.println("Fat Gram " + fat_gram);
        System.out.println("Total Calories " + total_calories);

        calories = fat_gram * 9;
        percentage = (calories / total_calories) * 100;

        System.out.println("The percentage of calories from fat = " + percentage);

        if (percentage < 30)
            System.out.println(msg);
        else (percentage > 30)
        System.out.println("The food is high on fat");
    }
}

image

arifqhuzairie commented 4 years ago

image

// developer: arif qhuzairie
// task: percentage of calories
public class calori {
    public static void main ( String [] args ){

        double fat_gram = 100;
        double total_calories = 900;
        double calories = fat_gram * 9;
        double percentage = (calories / total_calories) * 100;

        System.out.println(" fat_gram = " + 100);
        System.out.println(" total_calories = " + 900);
        System.out.println(" calories_from_fat =" + calories);

         String msg = " The food is high in fat";

        System.out.println(" The percentage of calories in fat =" + percentage );

        if (percentage > 30)
            System.out.println(msg);
        else
            System.out.println("The food is low in fat");

    }
}

image

Yazidrahman commented 4 years ago
//developer : yazid rahman 204608
public class taskcalories {
    public static void main (String [] args) {
        double fat_gram = 2;
        double total_calories = 200;
        double calories = 0;
        double percentage = 0.0;
        String notice = "The food is low in fat";

        System.out.println("Fat gram =" +fat_gram);
        System.out.println("Total calories =" +total_calories);
        calories = fat_gram * 9;
        percentage = (calories / total_calories) * 100;

        System.out.println("The percentage of calories from fat =" + percentage);

        if (percentage < 30)
            System.out.println(notice);

    }
}

image

image

batrisyaalwani commented 4 years ago
//Developer : Batrisya Alwani
//Task: calories
public class Main {

    public static void main(String[] args) {
        double fat_gram = 8;
        double total_calories = 80;
        double calories = fat_gram * 9;
        double percentage = (calories / total_calories) * 100;

        System.out.println("fat_gram = " + 8);
        System.out.println(" total_calories = " + 80);
        System.out.println(" calories_from_fat =" + calories);

        String msg = " The food is high in fat";

        System.out.println(" The percentage of calories in fat =" + percentage );

        if (percentage > 30)
            System.out.println(msg);
        else
            System.out.println("The food is low in fat");
    }
}

calories Screenshot (80)