เขียนโปรแกรม
การบ้าน โปรแกรม ภาษา C++
Jan 24th
ผมเรียนที่ มหาวิทยาลัยศรีนครินทรวิโรฒ นวัตกรรมสื่อสารสังคม เอกคอมพิวเตอร์เพื่อการสื่อสาร ปี 1 เทอร์ม 2
นี่คือ โจทย์ที่อาจารย์ให้มา ทำครับ ให้ใช้ภาษา C ++ ในการโปรแกรม
1) จงเขียนโปรแกรมแสดงชุดตัวเลขต่อไปนี้โดยใช้คำสั่งซ้ำ
a) 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
b) 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
c) 12 14 16 18 22 24 26 28 32 34 36 38 42 44 46 48
d) 2 4 8 16 32 64 128 256 512 1024
e) 1 1 2 3 5 8 13 21 34 55 89 More >
C++ โปรแกรมแปลงค่า องศาเซลเซียส เป็น ฟาเรนไฮต์ และ ฟาเรนไฮต์ เป็น เซลเซียส
Dec 7th
จงเขียนโปรแกรมแปลงค่า องศาเซลเซียส เป็น ฟาเรนไฮต์ และ ฟาเรนไฮต์ เป็น เซลเซียส จากสูตร F= 1.8C + 32 และ C= F – 32 / 1.8 โดยทำการรับค่าอุณหภูมิจาก Keyboard และทำการสร้างเป็นเมนูให้เลือกว่าจะแปลงเป็น CàF หรือ F à C จากนั้นให้ทำ การแปลงตามที่เลือกจากเมนูและแสดงผล
#include <iostream>
#include <cstdlib>using namespace std;
int main()
{
float fah,cel,ans;cout<< “Enter What You Want”<<endl;
cout<< “\t 1)Exchange Celcious to Fah”<<endl;
cout << “\t 2) Exchange Fah to celcious”<<endl;
cout << “Enter The Number :”;
cin >>ans;if (ans==1)
{
cout << “\nEnter Celcious number : “;
cin >>cel;
cout <<”\nThis is The Result = “<<1.8*cel+ 32;}
else if(ans==2)
{
cout << “\nEnter fahrenhine number : “;
cin >> fah;
cout <<”\n This is the result = “<<fah-32/1.8;
}system (“pause”);
return 0;
}
C++ โปรแกรมรับค่าราคาสินค้าแล้วนำไปเลือกลดราคา
Dec 7th
จงเขียนโปรแกรมรับค่าราคาสินค้า จาก Keyboard จากนั้นให้สร้างเมนูเพื่อเลือกอัตราส่วนลดใน 3 รายการคือ 5%, 10% และ 15% พร้อมแสดงผลราคาสินค้า พร้อมส่วนลดที่ได้ทำการเลือก และราคาส่วนลดที่คำนวณได้ และราคาสุทธิหลังลดแล้ว
ซ้อสโค้ด
#include <iostream>
#include <cstdlib>using namespace std;
int main()
{
float ans,prices;cout <<”Please Enter product prices”;
cin >>prices;
cout <<”\tWhat you want!”<<endl;
cout<< “\t 1)Discount 5%”<<endl;
cout <<”\t 2)Discount 10%”<<endl;
cout <<”\t 3)Discount 15%”<<endl;
cout <<”\t Enter The number : “;
cin >>ans;if(ans == 1)
{
cout <<”This is your Full prices :”<<prices<<endl;
cout <<”This is Your Discount prices :”<<prices*0.05<<endl;
cout <<”This is Your Result(already discount) : “<<prices-(prices*0.05)<<endl;
}else if (ans ==2 )
{
cout <<”This is Your Full Prices : “<<prices<<endl;
cout <<”this is Your Discount prices : “<<prices*0.10<<endl;
cout <<”This is Your total price (already discount) : “<<prices-(prices*0.1)<<endl;
}
else if (ans ==3)
{
cout << “This is your full prices : “<<prices <<endl;
cout <<”This is Your Discount Prices : “<<prices*0.15<<endl;
cout <<”This is Your Total Prices (Already Discount) : “<<prices-(prices*0.15)<<endl;
}
system(“pause”);
return 0;
}
คอมไพร์ ด้วย borland C++
C++ วิธีการคัดเลข ที่9หารลงตัว และไม่ใช่เลขคู่
Dec 6th
โจทย์มีอยู่ว่า
ให้เขียนโปรแกรมคัดเลข ที่9หารลงตัว และไม่ใช่เลขคู่ระหว่างตัวเลขตั่งแต่ 100-2000
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main ()
{
int number;
for (number=100;number <=2000;number++)
{
if (number%2 != 0 && number%9==0)
{cout<<setw(10)<<number;
}}
cout<<endl;
system (“pause”);
return 0;
}
