₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,802 members, 8,513,768 topics. Date: Thursday, 05 November 2026 at 01:30 PM

Toggle theme

Just A Prototype - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Just A Prototype (859 Views)

1 Reply

Just A Prototype by Nobody: 3:20pm On Oct 28, 2015
RATION.JAVA

import java.util.*;

public class Ration{
Scanner input = new Scanner(System.in);

public void Ration(){

//System.out.println("debug 1"wink;

boolean again = true; //loop ntoggle
System.out.println("Enter:\n 1 for starters ration\n 2 for finishers ration\n"wink;

while(again){
int type = input.nextInt();
switch(type){
case 1:
again = false;
starter();//call starter feed function NB: not yet implemented
break;
case 2:
again = false;
finisher(); //call finishers funtion
break;
default:
System.out.println("please try again: \n1--> \n 2-->finishers\n"wink;
break;
}
}
}


private void finisher(){
double cornP = 0.6; //%corn
double lyP = 0.0025; //%lysine
double methP = 0.0025; //%methionine
double boneP = 0.08; //%bone
double soyP = 0.3; //%roasted-soybean
double saltP = 0.01; //%table salt

System.out.println("Enter the weight of corn:"wink;
double corn = input.nextDouble(); //get the weight of corn to use

System.out.printf("Rations: \n--> corn = %.3fkg\n--> Soybean =[ %.3fkg\n--> Methionine = %.3fkg\n--> Bone = %.3fkg\n--> lysine = %.3fkg\n--> Salt'('NaCl')' = %.3fkg\n", corn, calc(corn, soyP, cornP), calc( corn, methP, cornP), calc(corn, boneP, cornP), calc( corn, lyP, cornP), calc(corn, saltP, cornP));
}


//calc func. accepts 3 var. corn weight, % of ingredient to calculate, and then % corn.
private double calc( double corn, double x, double cornP){

double amount = (corn * x) / cornP;
return amount;

}

private void starter(){
System.exit(1); //vestigial function.
//return;
}
}

Re: Just A Prototype by Nobody:
I am currently developing an algorithm that will calculate the quantity of ingredients reguired in my broilers home made feed according to their relative ratios by mass.


Corn (zea mays) is the anchor ingredient from which every other ingredient will be calculated.
1 Reply

HOT AND NEW: Prototype/dummy Home Automation System Using Raspberry & Android • Just A Few Days Of Coding • Just A Scenario... What Would U Have Done? • 2 • 3 • 4

Use Your Blog To Make Money, Get 36 Tried-and-true Ways To Promote Your Blog • Both Not Not Both • Teachmehowtocode Group Meetup In Abuja