Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. MainWindow::MainWindow(QWidget *parent) :
  5.     QMainWindow(parent),
  6.     ui(new Ui::MainWindow)
  7. {
  8.     ui->setupUi(this);
  9. }
  10.  
  11. MainWindow::~MainWindow()
  12. {
  13.     delete ui;
  14. }
  15.  
  16. void MainWindow::on_pushButton_clicked()
  17. {
  18.     int iA1 = ui->lineEdit->text().toInt();
  19.     int iD = ui->lineEdit_2->text().toInt();
  20.     int iN = ui->lineEdit_3->text().toInt();
  21.     if (iA1 == NULL || iD == NULL || iN == NULL)
  22.     {
  23.         ui->label_4->setText("Incorrect value");
  24.         return;
  25.     }
  26.     int iResultOne = iA1 + iD * ( iN -1 );
  27.     QString sResultOne = QString::number(iResultOne);
  28.     ui->label_4->setText(sResultOne);
  29.  
  30.     int iResultTwo = (iA1 + iResultOne) / 2 * iN;
  31.     QString sResultTwo = QString::number(iResultTwo);
  32.     ui->label_5->setText(sResultTwo);
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement