Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,561 members, 7,809,045 topics. Date: Thursday, 25 April 2024 at 09:43 PM

Just A Prototype - Programming - Nairaland

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

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)

(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: 3:28pm On Oct 28, 2015
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)

If Your Business Is Not Online In 2017, You Wuld Be Swimming Against The Current / Get It Done Today / Do U Knw Any Asp Tutorial Site Or Ebook With Js As The Default Scripting Lang??

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.