Langsung ke konten utama

Program Text to Speech Predikat Nilai Ujian Menggunakan Microsoft Visual C++ 2010

Berikut ini adalah source code untuk membuat program text to speech Predikat nilai ujian menggunakan Microsoft Visual C++ 2010.

#pragma once

namespace Aplikasi {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Speech::Synthesis;

/// <summary>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^  label1;
protected: 
private: System::Windows::Forms::TextBox^  textBox1;
private: System::Windows::Forms::Label^  label2;
private: System::Windows::Forms::TextBox^  textBox2;
private: System::Windows::Forms::Button^  button1;



private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
private: System::Windows::Forms::Button^  button2;
private:
int iNilai;

#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->label1 = (gcnew System::Windows::Forms::Label());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->label2 = (gcnew System::Windows::Forms::Label());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
// 
// label1
// 
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(12, 18);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(41, 13);
this->label1->TabIndex = 0;
this->label1->Text = L"Nama :";
// 
// textBox1
// 
this->textBox1->Location = System::Drawing::Point(60, 18);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(191, 20);
this->textBox1->TabIndex = 1;
// 
// label2
// 
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(15, 63);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(33, 13);
this->label2->TabIndex = 2;
this->label2->Text = L"Nilai :";
// 
// textBox2
// 
this->textBox2->Location = System::Drawing::Point(60, 63);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(191, 20);
this->textBox2->TabIndex = 3;
this->textBox2->TextChanged += gcnew System::EventHandler(this, &Form1::textBox2_TextChanged);
// 
// button1
// 
this->button1->Location = System::Drawing::Point(98, 133);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 4;
this->button1->Text = L"CEK";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
// 
// button2
// 
this->button2->Location = System::Drawing::Point(98, 182);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 5;
this->button2->Text = L"EXIT";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
// 
// Form1
// 
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 261);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->label2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion

private: System::Void textBox2_TextChanged(System::Object^  sender, System::EventArgs^  e) {
int iTemp;

if(Int32::TryParse(textBox2->Text, iTemp))
iNilai = Convert::ToInt32(textBox2->Text);
else
textBox2->Text = Convert::ToString(iNilai);
}


private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
SpeechSynthesizer^synth=gcnew SpeechSynthesizer();
if(iNilai>=80 && iNilai<=100){
synth->Speak("Hello "+textBox1->Text+", Nilaimu Sangat Bagus, Pertahankan");
}
else if(iNilai>=70 && iNilai<=79){
synth->Speak("Hello "+textBox1->Text+", Nilaimu Bagus, Tingkatkan");
}
else if(iNilai>=60 && iNilai<=69){
synth->Speak("Hello "+textBox1->Text+", Nilaimu Cukup, Jangan terlalu banyak bermain");
}
else if(iNilai>=50 && iNilai<=59){
synth->Speak("Hello "+textBox1->Text+", Nilaimu Kurang, Kamu Harus Belajar Lebih Giat Lagi");
}
else {
synth->Speak("Hello "+textBox1->Text+", Anda Gagal, Harus diulang Tahun Depan");
}
}

private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
Application::Exit();
}
};
}

Tampilan Output
Jika diklik tombol Cek akan mengeluarkan suara





















Selamat Mencoba.


#MicrosoftVisualC++
#TexttoSpeech

Komentar

Postingan populer dari blog ini

Program Menentukan Predikat Nilai Ujian Menggunakan C++

Berikut ini merupakan program untuk menentukan predikan nilai ujian menggunakan C++. #include <stdio.h> int main() { int nilai; printf("Input Nilai\t:"); scanf("%i", &nilai); if(nilai >= 80 && nilai <=100) { printf("Grade nilai\t: Sangat Baik"); } else if(nilai >= 70 && nilai <=79) { printf("Grade nilai\t: Baik"); } else if(nilai >= 60 && nilai <=69) { printf("Grade nilai\t: Cukup"); } else if(nilai >= 50 && nilai <=59) { printf("Grade nilai\t: Kurang"); } else { printf("Grade nilai\t: Gagal"); } return 0; } Outputnya sebagai berikut 

Program Penjumlahan Sederhana Menggunakan C++

Membuat program penjumlah, perkalian, pengurangan dan pembagian yang hasilnya dibuat dalam bentuk tabel dengan menggunakan C++. Berikut adalah Source Code nya : #include <iostream> using namespace std; int main ( ) { float a,b,c,d,e,f,total; cout<<"Masukan nilai a :"; cin>> a; cout<<endl; cout<<"Masukan nilai b :"; cin>> b; cout<<endl; c= a+b; d= a*b; e= a/b; f= a-b; total = c+d+e+f; cout<<"_________________________________________________________"<<endl; cout<<"|   A\t|   B\t|  A+B\t|  AxB\t|  A:B\t|  A-B\t| Total\t|"<<endl; cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; cout<<"| \t| \t| \t| \t| \t| \t| \t|"<<endl; cout<<"|   "<<a<<"\t|   "<<b<<"\t|  "<<c<<"\t|  "<<d<<"\t|  "<...

My Story

Hai..... Ini merupakan blog baru saya, saya adalah seorang pemimpi yang ingin mewujudkan semua mimpi saya, saya bukan anak yang mudah bergaul dengan orang baru, saya termasuk anak yang tertutup. disamping itu saya juga pelupa, dulu sewaktu saya kuliah di salah satu kampus negeri di Kota Hujan, saya pernah kesasar karna lupa jalan, sering juga saya disapa oleh teman saya tapi saya selalu lupa namanya dan akhirnya saya hanya tersenyum membalas sapanya. Di kampus saya yang lama saya dikenal sebagai mahasiswi tukang tidur. hampir setiap hari saya tertidur di kelas, penah satu kejadian kata teman saya sewaktu praktikum di Lab-Com teman saya bertanya kepada saya tentang yang diajarkan dosen dan waktu itu saya memang sedang mengantuk tetapi saya mencoba menjawab pertanyaan teman saya, tetapi di sela-sela saya sedang menjelaskan apa yang dia pertanyakan dia heran kenapa tiba-tiba saya diam dan ya saat itu saya tertidur ketika sedang menjawab pertanyaan teman yang disamping saya tersebut. da...