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 Simulasi Robot Menggunakan C++

Berikut ini merupakan Program Simulasi Robot menggunakan C++ dan ini merupakan tugas mata kuliah Teknologi Open Source di Universitas Harapan Medan. program ini meupakan program simulasi untuk menuju ruangan A atau ruangan B.  Berikut ini merupakan Source Code untuk programnya. #include <stdio.h> #include <conio.h> #include <windows.h> #include <cstdlib> #define WINDOWS 1 using namespace std; void clrscr() {   #ifdef WINDOWS   system("cls");   #endif } void gotoxy(int x, int y){    COORD k = {x,y};    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), k); } void map() { int a,b; a=1; while (a<=18) { int b=1; while(b<=31){ if (a==1 || b==1 || a==18 || b==31) {printf ("%");} else if (a==10 && b>=7 && b<=13) {printf ("%");} else if (a>=10 && a<14 && b==7) {printf ("%");} else if (a==14 && b>=7 &&...

Program Animasi Detak jantung Menggunakan C++

Berikut ini adalah program untuk menampilkan animasi detak jantung menggunakan bahasa pemerograman C++ Source Code: #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <windows.h> void hidup(); void mati(); void gotoab (int a, int b){ COORD koordinat; koordinat.X = a; koordinat.Y = b; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), koordinat); } const char * x; int main(){ hidup(); } void hidup(){ system("cls"); int I,repeat; char tekan; int kolom=2,baris=5; printf("——————————————————————————-\n"); printf("                              Animasi Detak Jantung\n"); printf("——————————————————————————-\n\n"); printf("|\n|\n|\n|\n") ; printf("___________________________\n"); printf("\n|\n|\n|\n|\n|\n"); printf("\n\n\n\n\n\nTekan a untuk mematikan pasien\n"); printf("Kondisi Pasien: Hidup\n\n"); printf(...