Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /***************************************************************************** 00002 * This program demonstrates how to use Class named Calculator in order to * 00003 * process common caluculating functions and display results via serial port * 00004 *****************************************************************************/ 00005 #include "mbed.h" 00006 #include "Calculator.h" 00007 #include "USBSerial.h" 00008 using namespace std; 00009 00010 //Virtual serial port over USB 00011 USBSerial serial; 00012 00013 int main() { 00014 float num1, num2; 00015 // Construct an instance of Calculator calc 00016 Calculator calc(0.0, 0.0);//(number1, number2); 00017 00018 wait(5); 00019 // Ask user for a number1 00020 serial.printf("Enter number1: "); 00021 serial.scanf("%f", &num1); 00022 // Ask user for a number2 00023 serial.printf("Enter numbe2: "); 00024 serial.scanf("\r\n%f", &num2); 00025 00026 // Set number1 and number2 to user inputs 00027 calc.setNumber1(num1); 00028 calc.setNumber2(num2); 00029 serial.printf("Number1 is: %.3f\r\n", calc.getNumber1()); 00030 serial.printf("Number2 is: %.3f\r\n", calc.getNumber2()); 00031 serial.printf("Sum: %.3f\r\n", calc.addNumbers()); 00032 serial.printf("Subtraction: %.3f\r\n", calc.subtractNumbers()); 00033 serial.printf("Multiplication: %.3f\r\n", calc.multiplyNumbers()); 00034 serial.printf("Division: %.3f\r\n", calc.divideNumbers()); 00035 }
Generated on Thu Jul 14 2022 21:02:42 by
1.7.2