Examination- ADF1 - Java Basic - Thi thực hành - T1907A
Thời Gian Bắt Đầu Thi : 15:20 - 16:20
Các bạn làm xong thi upload code lên chủ đề này cho thầy.
Gửi bài chậm 1 phút -> trừ 0.5 điểm
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![vuong huu phu [T2008A]](https://www.gravatar.com/avatar/307a5cf29780afab49706dc8b15b86c6.jpg?s=80&d=mm&r=g)
vuong huu phu
2021-03-03 08:49:52
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication22;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author Admin
*/
public class bai_2 {
public static void main(String[] args) {
String n;
Scanner scan = new Scanner(System.in);
System.out.println("Nhap chuoi ki tu ");
n = scan.nextLine();
StringTokenizer t = new StringTokenizer(n);
while (t.hasMoreTokens()){
System.out.println("Hien thi ");
System.out.println(t.nextToken());
}
}
}
![vuong huu phu [T2008A]](https://www.gravatar.com/avatar/307a5cf29780afab49706dc8b15b86c6.jpg?s=80&d=mm&r=g)
vuong huu phu
2021-03-03 08:49:27
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication22;
import java.util.Scanner;
/**
*
* @author Admin
*/
public class testbt1 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n;
ConversionUtil c = new ConversionUtil();
do {
menu();
System.out.println("Nhap su lua chon:");
n = scan.nextInt();
switch(n){
case 1:
System.out.println("Nhap do c ");
double cnd = scan.nextDouble();
System.out.println("do f = "+c.fahrenheitToCelsius(cnd));
break;
case 2:
System.out.println("Nhap do c ");
double fnd = scan.nextDouble();
System.out.println("do c = "+c.celciusToFahrenheit(fnd));
break;
}
} while (n!= 3);
}
public static void menu(){
System.out.println(" 1 kt do f");
System.out.println(" 2 kt do c");
}
}
![vuong huu phu [T2008A]](https://www.gravatar.com/avatar/307a5cf29780afab49706dc8b15b86c6.jpg?s=80&d=mm&r=g)
vuong huu phu
2021-03-03 08:49:09
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication22;
import java.util.Scanner;
/**
*
* @author Admin
*/
public class ConversionUtil {
double fDegree;
double cDegree;
public ConversionUtil() {
}
public ConversionUtil(double fDegree, double cDegree) {
this.fDegree = fDegree;
this.cDegree = cDegree;
}
public double getfDegree() {
return fDegree;
}
public void setfDegree(double fDegree) {
this.fDegree = fDegree;
}
public double getcDegree() {
return cDegree;
}
public void setcDegree(double cDegree) {
}
public double fahrenheitToCelsius(double fDegree){
double f;
f=(9.0/5)* (cDegree + 32) ;
return f;
}
public double celciusToFahrenheit(double cDegree){
double c ;
c = (05/9)*(fDegree - 32);
return c;
}
}
![Nguyên Phấn Đông [T2008A]](https://www.gravatar.com/avatar/c9c4f8f79ce35b9224637b6cc5fbe5c4.jpg?s=80&d=mm&r=g)
Nguyên Phấn Đông
2021-03-03 08:44:23
#ConversionUtil.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Exercise1;
/**
*
* @author dong
*/
public class ConversionUtil {
public static double celsiusToFahrenheit(double celsius) {
double f = (9.0 / 5) * celsius + 32;
return f;
}
public static double fahrenheitToCelsius(double fahrenheit) {
double c = (5.0 / 9) * (fahrenheit - 32);
return c;
}
}
#kiemtra.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Exercise1;
import java.util.Scanner;
/**
*
* @author dong
*/
public class kiemtra {
public static void main(String[] args) {
ConversionUtil ConversionUtil = new ConversionUtil();
Scanner scan = new Scanner(System.in);
int choose = scan.nextInt();
do{
System.out.println("1. Chuyển C thành F");
System.out.println("2. Chuyển F thành C");
System.out.println("3. Thoát");
System.out.println("Chon: ");
switch(choose) {
case 1:
System.out.println("Nhập số C: ");
double c = ConversionUtil.celsiusToFahrenheit(scan.nextInt());
System.out.println("F = " + c);
break;
case 2:
System.out.println("Nhập số F: ");
double f = ConversionUtil.fahrenheitToCelsius(scan.nextInt());
System.out.println("C = " + f);
break;
case 3:
System.out.println("Thoat chuong trinh.");
break;
}
}while(choose != 3);
}
}
#StringTokenizer.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Exercise2;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author dong
*/
public class StringTokenizer {
public StringTokenizer(String str) {
}
public static void main(String args[]) {
String str;
Scanner scan = new Scanner(System.in);
System.out.println("Mời bạn nhập chuỗi: ");
str = scan.nextLine();
StringTokenizer stringTokenizer = new StringTokenizer(str);
while (stringTokenizer.hasMoreTokens()) {
System.out.println(stringTokenizer.nextToken());
}
}
}
![Nguyễn Tiến Đạt [T2008A]](https://www.gravatar.com/avatar/b5819cd0adc95c727c7ad0c2bcf6098b.jpg?s=80&d=mm&r=g)
Nguyễn Tiến Đạt
2021-03-03 08:35:20
Excercise 1
#ConversionUtil.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lesson9.TestThithuchanh.Excercise1;
/**
*
* @author MyPC
*/
public class ConversionUtil {
double cDegree, fDegree;
public ConversionUtil() {
}
public ConversionUtil(double cDegree, double fDegree) {
this.cDegree = cDegree;
this.fDegree = fDegree;
}
public double getcDegree() {
return cDegree;
}
public void setcDegree(double cDegree) {
this.cDegree = cDegree;
}
public double getfDegree() {
return fDegree;
}
public void setfDegree(double fDegree) {
this.fDegree = fDegree;
}
public double fahrenheitToCelsius(double fDegree){
cDegree = (5.0/9) * (fDegree-32);
return cDegree;
}
public double celciusToFahrenheit(double cDegree){
fDegree = (9.0/5) * cDegree + 32;
return fDegree;
}
}
#Test.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lesson9.TestThithuchanh.Excercise1;
import java.util.Scanner;
/**
*
* @author MyPC
*/
public class Test {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
ConversionUtil check = new ConversionUtil();
int choose;
float x;
do{
showMenu();
System.out.println("Select program:");
choose = Integer.parseInt(scan.nextLine());
switch(choose){
case 1:
System.out.println("Fahreheit:");
x = Float.parseFloat(scan.nextLine());
System.out.println("Celsius: " + check.fahrenheitToCelsius(x));
break;
case 2:
System.out.println("Celsius:");
x = Float.parseFloat(scan.nextLine());
System.out.println("Fahreheit : " + check.celciusToFahrenheit(x));
break;
case 3:
System.out.println("Goodbye!!");
break;
default:
System.out.println("Wrong program!!");
break;
}
}while(choose != 3);
}
public static void showMenu(){
System.out.println("1. Fahrenheit to Celsius");
System.out.println("2. Celsius to Fahrenheit");
System.out.println("3. Exit");
}
}
Excercise 2
#Test.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lesson9.TestThithuchanh.Excercise2;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author MyPC
*/
public class Test {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("+Enter a string:");
String str = scan.nextLine();
System.out.println("+Result:");
StringTokenizer st = new StringTokenizer(str);
while(st.hasMoreTokens()){
System.out.println(" " + st.nextToken());
}
}
}
![Hoàng Quang Huy [C1907L]](https://www.gravatar.com/avatar/76e646e11f1674fba03bddd0ae020813.jpg?s=80&d=mm&r=g)
Hoàng Quang Huy
2020-04-07 09:07:07
package Lesson6_4_2020;
import java.util.Scanner;
public class ConversionUtil {
static double fahrenheitToCelcius(double fDegree){
double result = (fDegree-32) / 1.8;
return result;
}
static double celciusToFahrenheit(double cDegree){
double result = cDegree * 1.8 + 32;
return result;
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("F -> C");
System.out.println("Nhập độ F: ");
float f = input.nextFloat();
System.out.println(fahrenheitToCelcius(f));
System.out.println("C -> F");
System.out.println("Nhập độ C: ");
float c = input.nextFloat();
System.out.println(celciusToFahrenheit(c));
}
}
-------------------------------------------------------------------------------------
package Lesson6_4_2020;
import java.util.StringTokenizer;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
//Bài 2
Scanner input = new Scanner(System.in);
System.out.println("Enter a string: ");
String str = input.nextLine();
StringTokenizer st = new StringTokenizer(str);
System.out.println("Result: ");
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
}
}
![Nguyễn Hoàng Anh [C1907L]](https://www.gravatar.com/avatar/5b7bb435cae0d0a0fd414f6fdd0adc87.jpg?s=80&d=mm&r=g)
Nguyễn Hoàng Anh
2020-04-06 14:42:02
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package april6;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author Redmibook 14
*/
public class ConversionUtil {
double fahrenheitToCelsius(double fDegree) {
double celsius = (fDegree - 32) / 1.8;
System.out.println(celsius);
return celsius;
}
double celciusToFahrenheit(double cDegree) {
double fahrenheit = (cDegree * 1.8) + 32;
System.out.println(fahrenheit);
return fahrenheit;
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (true) {
System.out.println("1.Celcius To Fahrenheit");
System.out.println("2.Fahrenheit To Celsius");
System.out.println("3.String Tokenizer");
System.out.println("4.Ẽxit");
int choice = Integer.parseInt(input.nextLine());
switch (choice) {
case 1:
System.out.println("Input Celcius :");
ConversionUtil ch = new ConversionUtil();
double cel = Double.parseDouble(input.nextLine());
ch.celciusToFahrenheit(cel);
break;
case 2:
System.out.println("Input Fahrenheit :");
ConversionUtil chs = new ConversionUtil();
double fa = Double.parseDouble(input.nextLine());
chs.fahrenheitToCelsius(fa);
break;
case 3:
System.out.println("Input a line :");
String line = input.nextLine();
StringTokenizer st1 = new StringTokenizer(line);
System.out.println("Token print :");
while (st1.hasMoreTokens()) {
System.out.println(st1.nextToken());
}
break;
case 4:
return;
}
}
}
}
![Vũ Việt Đức [C1907L]](https://www.gravatar.com/avatar/114894070fbd15fc0c29ffdeab37f4b5.jpg?s=80&d=mm&r=g)
Vũ Việt Đức
2020-04-06 14:10:19
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lession10;
/**
*
* @author ADMIN
*/
public class ConversionUtil {
double fahrenheitToCelsius(double fDegree){
return 5*(fDegree-32)/9;
}
double celciusToFahrenheit(double cDegree){
return (9*cDegree/5)+32;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lession10;
import java.util.Scanner;
/**
*
* @author ADMIN
*/
public class Driver {
public static void main(String[] args) {
double fahrenheit, cecius;
ConversionUtil cvu = new ConversionUtil();
Scanner scanner = new Scanner(System.in);
System.out.println("Nhập Fahrenheit: ");
fahrenheit = scanner.nextDouble();
System.out.println(fahrenheit + " độ F = " + cvu.fahrenheitToCelsius(fahrenheit) + " độ C");
System.out.println("Nhập Celcius: ");
cecius = scanner.nextDouble();
System.out.println(cecius + " độ C = " + cvu.celciusToFahrenheit(cecius) + " độ F");
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lession10;
import java.util.Scanner;
/**
*
* @author ADMIN
*/
public class Ex2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String text = scanner.nextLine();
System.out.println("Result: ");
String[] name = text.split(" ");
for (String n: name) {
System.out.println(n);
}
}
}
![hoangkhiem [C1907L]](https://www.gravatar.com/avatar/d3627ce786997fab24d1b790c91c6368.jpg?s=80&d=mm&r=g)
hoangkhiem
2020-04-06 14:10:13
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package baitap64Examination;
import java.util.Scanner;
/**
*
* @author Admin
*/
public class ConversionUtil {
public double fahrenheitToCelsius( double fDegree){
return 5 * (fDegree - 32) / 9;
}
public double celciusToFahrenheit(double cDegree){
return (9 * cDegree / 5) + 32;
}
public static void main(String[] args) {
ConversionUtil x = new ConversionUtil();
Scanner nhap = new Scanner(System.in);
System.out.println("Nhập vào độ Celcius bạn cần đổi là: ");
double cecius = nhap.nextDouble();
System.out.println("cecius đô C = " + x.celciusToFahrenheit(cecius) + " độ F");
System.out.println("Nhập vào độ Fahrenheit bạn cần đổi là: ");
double fahrenheit = nhap.nextDouble();
System.out.println(" cecius độ F = " + x.fahrenheitToCelsius(fahrenheit) + " độ C");
}
}
![trung [C1907L]](https://www.gravatar.com/avatar/67c23432e4710f33dd14e580d41b0379.jpg?s=80&d=mm&r=g)
trung
2020-04-06 14:08:02
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author prdox
*/
public class ConversionUtil {
public double fahrenheitToCelsius(double fDegree) {
return (fDegree - 32)*5/9;
}
public double celciusToFahrenheit(double cDegree){
return cDegree*9/5 +32;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author prdox
*/
public class Main {
public static void main(String[] args) {
ConversionUtil conv = new ConversionUtil();
System.out.println("10 C -> F : "+conv.celciusToFahrenheit(10));
System.out.println("100 F -> C : "+conv.fahrenheitToCelsius(100));
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package newpackage2;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author prdox
*/
public class tokenize {
public static void main(String[] args) {
System.out.println("Enter a string: ");
Scanner inp = new Scanner(System.in);
String input = inp.nextLine();
StringTokenizer tok = new StringTokenizer(input," ",false);
while (tok.hasMoreTokens())
System.out.println(tok.nextToken());
}
}