Homework Solution: 1. You will need to install the (free) program Xcode 8 using the App Store on your Mac (previous versions of Xcode will NOT wo…

    Materials
    1. You will need to install the (free) program Xcode 8 using the App Store on your Mac (previous versions of Xcode will NOT work). It is highly recommended that you do this immediately so that if you have any problems getting Xcode to work, you have time to get help from Piazza and/or the TAs in their office hours.
    2.
    3. A link to the video of the lectures can be found in the same place you found this document.
    Required Tasks
    1. Get the Calculator working as demonstrated in lectures 1 and 2.
    2.
    3. Your Calculator already works with floating point numbers (e.g. if you touch 3 ÷ 4 =, it will properly show 0.75), however, there is no way for the user to enter a floating point number directly. Fix this by allowing legal floating point numbers to be entered (e.g. "192.168.0.1" is not a legal floating point number!). You will need to have a "." button in your calculator. Don't worry too much about precision or significant digits in this assignment (doing so is Extra Credit).
    4.
    5. Add some more operations buttons to your calculator such that it has at least a dozen operations total (it can have even more if you like). You can choose whatever operations appeal to you. The buttons must arrange themselves nicely in portrait and landscape modes on all iPhone 6's and 7's.
    6.
    7. Use color to make your UI look nice. At the very least, your operations buttons must be a different color than your keypad buttons, but otherwise you can use color in whatever way you think looks nice.
    8.
    9. Add a Bool property to your CalculatorBrain called resultIsPending which returns whether there is a binary operation pending.
    10.
    11. Add a String property to your CalculatorBrain called description which returns a description of the sequence of operands and operations that led to the value returned by result (or the result so far if resultIsPending). The character = (the equals sign) should never appear in this description, nor should … (ellipses).
    12.
    13. Implement a UILabel in your UI which shows the sequence of operands and operations that led to (or is leading to if resultIsPending) what is (or "will be" if resultIsPending) showing in the display. If resultIsPending is true, put . . . on the end of the UILabel, else put =. If the userIsInTheMiddleOfTyping, you can leave the UILabel showing whatever was there before the user started typing the number. Examples ...
    1. touching 7 + would show "7 + …" (with 7 still in the display)
    2. 7 + 9 would show "7 + …" (9 in the display)
    3. 7 + 9 = would show "7 + 9 =" (16 in the display)
    4. 7 + 9 = √ would show "√(7 + 9) =" (4 in the display)
    5. 7 + 9 = √ + 2 = would show "√(7 + 9) + 2 =" (6 in the display)
    6. 7 + 9 √ would show "7 + √(9) …" (3 in the display)
    7. 7 + 9 √ = would show "7 + √(9) =" (10 in the display)
    8. 7 + 9 = + 6 = + 3 = would show "7 + 9 + 6 + 3 =" (25 in the display)
    9. 7 + 9 = √ 6 + 3 = would show "6 + 3 =" (9 in the display)
    10. 5 + 6 = 7 3 would show "5 + 6 =" (73 in the display)
    11. 4 × Π = would show "4 × Π =" (12.5663706143592 in the display)
    14.
    15. Add a C button that clears everything (your display, the new UILabel you added above, any pending binary operations, etc.). Ideally, this should leave your Calculator in the same state it was in when you launched it.

    Expert Answer

     
    import java.awt.Image;
    import java.io.IOException;

    Materials
    1. You everyure insufficiency to induct the (free) program Xcode 8 using the App Store on your Mac (antecedent versions of Xcode everyure NOT composition). It is extremely recommended that you do this straighthabit so that if you possess any problems secureting Xcode to composition, you possess date to secure aid from Piazza and/or the TAs in their service hours.
    2.
    3. A associate to the video of the lectures can be root in the selfselfidentical locate you root this instrument.
    Required Tasks
    1. Secure the Calculator compositioning as demonstrated in lectures 1 and 2.
    2.
    3. Your Calculator already compositions with shapeless summit quantity (e.g. if you affect 3 ÷ 4 =, it everyure uprightly demonstrationance 0.75), at-last, there is no habit control the rightr to invade a shapeless summit estimate straightway. Fix this by everyowing everyowable shapeless summit quantity to be invadeed (e.g. “192.168.0.1” is referable a everyowable shapeless summit estimate!). You everyure insufficiency to possess a “.” dot in your calculator. Don’t harass as-well fur encircling exactness or speaking digits in this enactment (doing so is Extra Credit).
    4.
    5. Gather some further influences dots to your calculator such that it has at smallest a dozen influences aggregate (it can possess equable further if you approve). You can prefer whatever influences invite to you. The dots must place themselves finely in image and field modes on every iPhone 6’s and 7’s.
    6.
    7. Right hue to constitute your UI seem fine. At the very smallest, your influences dots must be a incongruous hue than your keypad dots, notwithstanding otherwise you can right hue in whatever habit you contemplate seems fine.
    8.
    9. Gather a Bool nature to your CalculatorBrain determined purposeIsPending which profits whether there is a binary influence pending.
    10.
    11. Gather a String nature to your CalculatorBrain determined title which profits a title of the continuity of operands and influences that led to the appreciate returned by purpose (or the purpose so distant if purposeIsPending). The disposition = (the equals premonition) should never demonstration in this title, nor should … (ellipses).
    12.
    13. Implement a UILabel in your UI which demonstrationances the continuity of operands and influences that led to (or is immanent to if purposeIsPending) what is (or “allure be” if purposeIsPending) demonstrationanceing in the expose. If purposeIsPending is gentleman, set-down . . . on the purpose of the UILabel, else set-down =. If the rightrIsInTheMiddleOfTyping, you can permission the UILabel demonstrationanceing whatever was there precedently the rightr established typing the estimate. Examples …
    1. affecting 7 + would demonstrationance “7 + …” (with 7 tranquil in the expose)
    2. 7 + 9 would demonstrationance “7 + …” (9 in the expose)
    3. 7 + 9 = would demonstrationance “7 + 9 =” (16 in the expose)
    4. 7 + 9 = √ would demonstrationance “√(7 + 9) =” (4 in the expose)
    5. 7 + 9 = √ + 2 = would demonstrationance “√(7 + 9) + 2 =” (6 in the expose)
    6. 7 + 9 √ would demonstrationance “7 + √(9) …” (3 in the expose)
    7. 7 + 9 √ = would demonstrationance “7 + √(9) =” (10 in the expose)
    8. 7 + 9 = + 6 = + 3 = would demonstrationance “7 + 9 + 6 + 3 =” (25 in the expose)
    9. 7 + 9 = √ 6 + 3 = would demonstrationance “6 + 3 =” (9 in the expose)
    10. 5 + 6 = 7 3 would demonstrationance “5 + 6 =” (73 in the expose)
    11. 4 × Π = would demonstrationance “4 × Π =” (12.5663706143592 in the expose)
    14.
    15. Gather a C dot that clears everything (your expose, the odd UILabel you external over, any pending binary influences, expectation.). Ideally, this should permission your Calculator in the selfselfidentical declare it was in when you agoing it.

    Expert Exculpation

     

    import java.awt.Image;
    import java.io.IOException;
    
    import javax.imageio.ImageIO;
    import javax.swing.*;
    
    social assort JButtonIcon {
        JButtonIcon(){  
            /* JEffect is a summit raze container (window)
             * where we would be gathering our dot
             */
            JEffect effect=odd JFrame();  
                              
            // Creating Dot          
            JDot b = odd JButton();
            fathom {
                Image img = ImageIO.read(getClass().getResource("play.gif"));
                b.setIcon(odd ImageIcon(img));
              } lay-hands-on (IOException ex) {
              }
            
            b.setBounds(50,50,90, 50);  
                 
            //Adding dot onto the effect
            effect.add(b);  
                      
            // Setting Effect greatness. This is the window greatness
            effect.setSize(300,200);  
            
            effect.setLayout(null);  
            effect.setVisible(true);  
                      
            effect.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
                      
        }  
                  
        social static wanting ocean(String[] args) {  
                odd JButtonIcon();  
        }  
    }