Розмір відео: 1280 X 720853 X 480640 X 360
Показувати елементи керування програвачем
Автоматичне відтворення
Автоповтор
// sample code, copy and paste, have fun!#include void setup() { Serial.begin(9600); // Initialize serial communication}void loop() { // Input metrics float peRatio, debtToEquityRatio, profitMargin; // Prompt user for input using Serial Monitor Serial.println("Enter the P/E Ratio:"); while (!Serial.available()) { // Wait for user input } peRatio = Serial.parseFloat(); Serial.println("Enter the Debt to Equity Ratio:"); while (!Serial.available()) { // Wait for user input } debtToEquityRatio = Serial.parseFloat(); Serial.println("Enter the Profit Margin:"); while (!Serial.available()) { // Wait for user input } profitMargin = Serial.parseFloat(); // Define scoring thresholds float peThresholdLow = 10.0; float peThresholdMedium = 15.0; float debtEquityThresholdLow = 0.5; float debtEquityThresholdMedium = 1.0; float profitMarginThresholdHigh = 15.0; float profitMarginThresholdMedium = 10.0; // Initialize scores int peScore = 0; int debtEquityScore = 0; int profitMarginScore = 0; // Scoring for P/E Ratio if (peRatio < peThresholdLow) { peScore = 3; } else if (peRatio < peThresholdMedium) { peScore = 2; } else { peScore = 1; } // Scoring for Debt to Equity Ratio if (debtToEquityRatio < debtEquityThresholdLow) { debtEquityScore = 3; } else if (debtToEquityRatio < debtEquityThresholdMedium) { debtEquityScore = 2; } else { debtEquityScore = 1; } // Scoring for Profit Margin if (profitMargin > profitMarginThresholdHigh) { profitMarginScore = 3; } else if (profitMargin > profitMarginThresholdMedium) { profitMarginScore = 2; } else { profitMarginScore = 1; } // Calculate overall stock score int overallScore = peScore + debtEquityScore + profitMarginScore; // Display individual scores and overall score Serial.println("Individual Scores:"); Serial.print("P/E Ratio Score: "); Serial.println(peScore); Serial.print("Debt to Equity Ratio Score: "); Serial.println(debtEquityScore); Serial.print("Profit Margin Score: "); Serial.println(profitMarginScore); Serial.print("Overall Stock Score: "); Serial.println(overallScore); // Wait for the next input delay(5000);}
// sample code, copy and paste, have fun!
#include
void setup() {
Serial.begin(9600); // Initialize serial communication
}
void loop() {
// Input metrics
float peRatio, debtToEquityRatio, profitMargin;
// Prompt user for input using Serial Monitor
Serial.println("Enter the P/E Ratio:");
while (!Serial.available()) {
// Wait for user input
}
peRatio = Serial.parseFloat();
Serial.println("Enter the Debt to Equity Ratio:");
while (!Serial.available()) {
// Wait for user input
}
debtToEquityRatio = Serial.parseFloat();
Serial.println("Enter the Profit Margin:");
while (!Serial.available()) {
// Wait for user input
}
profitMargin = Serial.parseFloat();
// Define scoring thresholds
float peThresholdLow = 10.0;
float peThresholdMedium = 15.0;
float debtEquityThresholdLow = 0.5;
float debtEquityThresholdMedium = 1.0;
float profitMarginThresholdHigh = 15.0;
float profitMarginThresholdMedium = 10.0;
// Initialize scores
int peScore = 0;
int debtEquityScore = 0;
int profitMarginScore = 0;
// Scoring for P/E Ratio
if (peRatio < peThresholdLow) {
peScore = 3;
} else if (peRatio < peThresholdMedium) {
peScore = 2;
} else {
peScore = 1;
}
// Scoring for Debt to Equity Ratio
if (debtToEquityRatio < debtEquityThresholdLow) {
debtEquityScore = 3;
} else if (debtToEquityRatio < debtEquityThresholdMedium) {
debtEquityScore = 2;
} else {
debtEquityScore = 1;
}
// Scoring for Profit Margin
if (profitMargin > profitMarginThresholdHigh) {
profitMarginScore = 3;
} else if (profitMargin > profitMarginThresholdMedium) {
profitMarginScore = 2;
} else {
profitMarginScore = 1;
}
// Calculate overall stock score
int overallScore = peScore + debtEquityScore + profitMarginScore;
// Display individual scores and overall score
Serial.println("
Individual Scores:");
Serial.print("P/E Ratio Score: ");
Serial.println(peScore);
Serial.print("Debt to Equity Ratio Score: ");
Serial.println(debtEquityScore);
Serial.print("Profit Margin Score: ");
Serial.println(profitMarginScore);
Serial.print("
Overall Stock Score: ");
Serial.println(overallScore);
// Wait for the next input
delay(5000);
}